Sign in to follow this  
Fassbinderfan

Class in a list, addin values

Recommended Posts

I have this class Project: class Project { public: char name[40]; int duration; }; I wanted to put it in a list and add some values,. But it aint working. Any help appreciated. list <Project> proj; proj.push_front (Project("AA", 1));

Share this post


Link to post
Share on other sites
Quote:
Original post by Molle85

class Project {
public:
Project( char* n, int dur ) : duration(dur)
{
strcpy( name, n );
}
char name[40];
int duration;
};


Project(const char * n, int dur) : duration(dur)
{
strncpy(name, n, 39);
}


In the brief example above, we see why use of std::string is generally recommended.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this