Hmmm... I'm trying to call a class and it doesn't work and i get this error
/home/XXXX/Desktop/language/main.cpp|13|error: expected constructor, destructor, or type conversion before ‘.’ token|

The syntax is:

print.base="print";

this simple method call returns an error.

Am i really doing something wrong, seeing as i've already looked in my book and they said i had it right.

What's wrong- i have no idea!!

Show the line where you instantiate print.

If base is a method call it would have to look something like print.base("print"); You can't set a method equal to a string like that (only a member variable named base), and you need the () when calling a method. If this still doesn't solve the problem, post the class definition for cmd.

ok, base isn't a method, and I'm smart enough to know that!

so, here's the definition:

class cmd
{
string base;
char extension[80];
};

yes, that's really all there is, it's just a way for me to organize the commands.

I'm smart enough to know that!

Wasn't insinuating anything less, lol. It was just that you had said

this simple method call

Are you including the header file or whatnot for class cmd in the file in which you have placed the first two code snippets?

ok, base isn't a method, and I'm smart enough to know that!

so, here's the definition:

class cmd
{
string base;
char extension[80];
};

yes, that's really all there is, it's just a way for me to organize the commands.

Wooah don't get sassy or nobody will help you. You need to declare the member variables as public if you are going to access them directly (Instead of using getter, setter methods).

commented: Yes, I totally flew past that +7

Oh jeez. Yes! Class members are private by default. Thanks hag++ for having sharper eyes!

o! thanks sooooo much!

wow, i've had that problem and just work around it until i realize the same thing for something else! thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.