assignment in class

R

Raptor

Is it right, that you cannot assign a value to a non-static variable in a class?
 
D

Deakon

Raptor said:
Is it right, that you cannot assign a value to a non-static variable
in a class?

If you wish to 'assign' a value to a variable within a class...to
default it to something, you must do it in the constructor.

class MyClass
{
private:
int blah;
public:
MyClass(): blah (0)
{ }
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,264
Latest member
FletcherDa

Latest Threads

Top