The complexities of maintaining a list are reduced considerably if you use a sentinel
value. See: Linked List reversal Linked List reversal
The complexities of maintaining a list are reduced considerably if you use a sentinel
value. See: Linked List reversal
The complexities of maintaining a list are reduced considerably if you use a sentinel
value. See: Linked List reversal
class Test { public: void get(int &, std::string &); private: int int1; std::string string1; };
class Test
{
public:
void get(int &, std::string &);
private:
int int1;
std::string string1;
};
This is not your grandad's C. Thisgrandpa's C; this is C++C++. structs etcstruct live in the same namespace as other types and objects. Also multiple declarations on the same line is frowned upon so split the above into multiple declarations to make it clear wheat is happening.
Again Test
in the name.
Rather than adding two different types that have nothing to do with your list.
class TestList
Rather than adding two different types that have nothing to do with your list.
void add(int &, std::string &);
PutBut you should probably also define an operator<<
for your class that calls it. Most people basically do away with the print and just put the logic of the print in operator>>
and make it a friend of the class.
class Test { public: void get(int &, std::string &); private: int int1; std::string string1; };
This is not your grandad's C. This is C++. structs etc live in the same namespace as other types and objects. Also multiple declarations on the same line is frowned upon so split the above into multiple declarations to make it clear wheat is happening.
Again Test
in the name.
Rather than adding two different types that have nothing to do with your list.
void add(int &, std::string &);
Put you should probably also define an operator<<
for your class that calls it. Most people basically do away with the print and just put the logic of the print in operator>>
and make it a friend of the class.
class Test
{
public:
void get(int &, std::string &);
private:
int int1;
std::string string1;
};
This is not your grandpa's C; this is C++. struct live in the same namespace as other types and objects. Also multiple declarations on the same line is frowned upon so split the above into multiple declarations to make it clear wheat is happening.
Again Test
in the name.
class TestList
Rather than adding two different types that have nothing to do with your list.
void add(int &, std::string &);
But you should probably also define an operator<<
for your class that calls it. Most people basically do away with the print and just put the logic of the print in operator>>
and make it a friend of the class.