Problem With Visual C++

M

mpaliath

Suppose I have 2 classes X & Y declared in X.h & Y.h and defined in
X.cpp & Y.cpp. If I have a function which returns an object of X in Y
and one which returns an object of X in Y how where and in what order
do I include the files X,Y.cpp,.h

Also sometimes while working in Visual C++, after adding some code
manually I find that some classes dissapear from the class view tab. If
I try to add the class again with the already existing files it shows
that the class already exists. Whats happening??
 
A

adbarnet

By the way - the other problem is MS VC specific, but try deleting the class
wizard file (.clw extension) and re-opeining the workspace).

Aiden
 
I

Ioannis Vranos

Suppose I have 2 classes X & Y declared in X.h & Y.h and defined in
X.cpp & Y.cpp. If I have a function which returns an object of X in Y
and one which returns an object of X in Y how where and in what order
do I include the files X,Y.cpp,.h


class Y;

class X
{
public:
void somefunc(Y obj);
};


class Y
{
public:
void somefunc(X obj);
};


void X::somefunc(Y obj) {}
void Y::somefunc(X obj) {}


int main()
{
X x;

Y y;

x.somefunc(y);

y.somefunc(x);
}
 
M

mpaliath

well Ioannis,

I've tried that but it shows the error

error C2501: 'Y' : missing storage-class or type specifiers

by the way I use Visual C++
 
K

Karl Heinz Buchegger

well Ioannis,

I've tried that but it shows the error

error C2501: 'Y' : missing storage-class or type specifiers

by the way I use Visual C++

replace the pass-per-value with a pass-per-reference

class X
{
public:
void somefunc(const Y& obj);
};
 
I

Ioannis Vranos

well Ioannis,

I've tried that but it shows the error

error C2501: 'Y' : missing storage-class or type specifiers

by the way I use Visual C++


It compiles with the last version of VC++ here with only a stupid
warning which looks it is fixed in current VC++ 2005 beta:


c:\c\temp.cpp(27) : warning C4700: local variable 'y' used without
having been i
nitialized


But it compiles. What version of VC++ are you using?
 
M

mpaliath

I use Visual C++ 6.0 . I dont have access to VC++2004 or 5 so is there
any way to get around this problem
 
I

Ioannis Vranos

I use Visual C++ 6.0 . I dont have access to VC++2004 or 5 so is there
any way to get around this problem


Unfortunately, VC++ 6 is very old and is not much ISO C++ compliant.
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top