Strange class definition

S

seema

I am new to C++ programming, can somebody explain what is this
me_xx is it a type name or instantiation of class Final. And also
how to use me_xx ?
struct IViewObjectEx
{

public:
void solv()
{
}

};

class XViewObject : public IViewObjectEx {

public:
virtual void Draw()=0;

};

class Final: public XViewObject
{
public :
void Draw(){
cout <<"Drawing thru Draw()"<<endl;
}

} me_xx;

int main(){
Final pre;
}

Thanks in advance,
Seema
 
V

Victor Bazarov

seema said:
I am new to C++ programming, can somebody explain what is this
me_xx is it a type name or instantiation of class Final. And also
how to use me_xx ?

It's an instance. It's like this: C++ allows to define a class with or
without declaring something in the same statement. In actuality those
are two separate grammar constructs, IIRC, but they look very similar.

IOW, you can write

struct A {}; // class definition

or

struct A {} a; // class definition _and_ an object declaration

Use 'me_xx' just like you would any other object of type 'Final'.
struct IViewObjectEx
{

public:
void solv()
{
}

};

class XViewObject : public IViewObjectEx {

public:
virtual void Draw()=0;

};

class Final: public XViewObject
{
public :
void Draw(){
cout <<"Drawing thru Draw()"<<endl;
}

} me_xx;

int main(){
Final pre;
}

Thanks in advance,
Seema

V
 

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

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top