473,545 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem With Visual C++

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??

Jul 23 '05 #1
7 1194
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

"adbarnet" <ad******@barne t.com> wrote in message
news:42******** **@127.0.0.1...

I assume you meant X includes Y and Y includes X? In that case you have a
circular dependency, which can be pretty heinous. The best solution is to
re-work the code to remove one dependency (consider combining X and Y via
a third class Z to achieve the intended goal i.e. Z includes X and Y).
Alternatively - can any of the declarations of X or Y be made into
references or pointers? That way you can forward declare them rather that
including the entire declaration.

<mp******@gmail .com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.com.. .
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??


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jul 23 '05 #2
mp******@gmail. com wrote:
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);
}


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #3
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++

Jul 23 '05 #4
mp******@gmail. com wrote:

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);
};
--
Karl Heinz Buchegger
kb******@gascad .at
Jul 23 '05 #5
mp******@gmail. com wrote:
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(2 7) : warning C4700: local variable 'y' used without
having been i
nitialized
But it compiles. What version of VC++ are you using?

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #6
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

Jul 23 '05 #7
mp******@gmail. com wrote:
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.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
10614
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using namespace std; : : vector<string>* getTyphoon()
36
2440
by: AussieRules | last post by:
Hi, I want to use the user color scheme to set the color of my forms. I now I have to use the. System.Drawing.SystemColors, but which color is the color of a form background as used in other applications. In the end all I want to do is form1.backcolor = system.whatever.color
13
3915
by: Lee Newson | last post by:
Hi, I have just written my first application using VB.NET. The app works fine when i am running it within .NET for debugging purposes, however when i try to run the app from the .exe file that .NET creates i get the following error message: "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in VisioTimeline.exe
0
1929
by: simon.hudon | last post by:
Hi everyone, I have a strange problem with precompiled headers with VC8. I have the problem while trying to use a precompiled header to build another precompiled header. I tried the sample code provided on msdn for the use of /Yu /Yc and while it works well with VC++ 7.0, it doesn't with VC++ 8.0...
9
13248
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include <hash_map>//from Standard template library //and some other headers
1
5431
by: Arsalan Ahmad | last post by:
Hi all, I am trying to compile some source files using makefile. While compiling I am getting errors as shown below. Any idea how can I solve this problem. I believe I need to add some preprocessor directives but I dont know which one. Thanks, Arsalan
4
2145
by: sqlguy | last post by:
Why do we have to contact MS for a problem that has been with this compiler from at least the beta of VS 20005. I am so sick and tired of the 30 - 40 clicks it takes to dismiss VS when there is a problem. Can they not just post the fix. I see no reason to contact MS since I have most likely sent about 1500 dumps to them and I would think...
7
3427
by: sturlamolden | last post by:
This question has been asked many times, and last time I was accused of spreading FUD. So now I will rather propose a solution. The reason for the problem is as follows: The binary installer for Python built by te python.org team is compiled with Microsoft Visual Studio 2003. It is linked with the C runtime msvcrt71.dll. The copyright to...
16
1751
by: Bill Nguyen | last post by:
I'm running into a very weird problem regarding subtraction. Subtraction behaves as if it's an addition in the below sub txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0") txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
3
2913
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it brings me to the dir: C:\Visual Studio 2005\WebSites\WebSite1, it creates default.aspx and default.aspx.vb and I pasted the following code into...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.