?
Solved

Function not being added to header file.

Posted on 2004-08-09
8
Medium Priority
?
279 Views
Last Modified: 2010-04-01
Im reading a book in visual c++, Im trying to use the Add Member Function wizard, but it wont add the function definition to the header, but it does add to the cpp file. It seems it WILL add to the header if both the type and param are the class name. Anyone know how i can fix this, or at least why its not adding?
0
Comment
Question by:Monstrosity_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11757287
> Im trying to use the Add Member Function wizard, but it wont add the function definition to the header.
Are you really sure? That's not normal. Maybe you are not noticing that some added function declarations are "grayed", but there exist.
Try to compile, if succeed, then function declaration is there.
0
 

Author Comment

by:Monstrosity_
ID: 11757376
hmm... i could try... but even in the book it shows what the final code SHOULD look like and only one of the three that it says to add accually gets added to the header. It doesnt even show up in the class view list. From what ive learnt it will compile either way, just a matter of wiether or not you want inline or not wouldnt it?

CBox operator+(const CBox& aBox) const   gets added but..
CBox operator*(int n) const  does not, but the cpp file shows it as,
CBox CBox::operator*(...) const ... so there should be a definition in the header right? otherwise whats the point of CBox:: ? Now im really confused ;)
0
 

Author Comment

by:Monstrosity_
ID: 11759623
I just tried to add the member funtcions and compile like you said and heres the debug info...

--------------------Configuration: classes - Win32 Debug--------------------
Compiling...
Box.cpp
C:\WINDOWS\Desktop\C\VC6\classes\Box.cpp(27) : error C2039: '*' : is not a member of 'CBox'
        c:\windows\desktop\c\vc6\classes\box.h(13) : see declaration of 'CBox'
C:\WINDOWS\Desktop\C\VC6\classes\Box.cpp(28) : error C2270: '*' : modifiers not allowed on nonmember functions
Error executing cl.exe.

classes.exe - 2 error(s), 0 warning(s)

The line of code it refers to is the function added to the .cpp but not .h file..

CBox CBox::operator *(int n) const {}


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 11761370
In your class header there should be lines like that:

      //{{AFX_VIRTUAL(CTestDlg)

      //}}AFX_VIRTUAL


Class Wizard adds new prototypes between these two comments. If these are missing or changed, it will fail.

Regards, Alex

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 11761389
Also these two comments are needed for handler functions (non-virtual)

      //{{AFX_MSG(CTestDlg)

      //}}AFX_MSG

Regards, Alex


0
 

Author Comment

by:Monstrosity_
ID: 11767757
I added both those lines and still does same thing...
wtf.. maybe something got messed and needs reinstall
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 11767840
There are many situations in where Visual Studio IDE don't work as expected, some bug has been corrected in differents Software Packs (up to SP6 I guess) but some others no.
So, if after reinstalling still works the same, don't worry and do it manually.
0
 

Author Comment

by:Monstrosity_
ID: 11769511
reinstalled and same f-ing thing... this really p's me off. But i guess ill have to live with doing it manually... i'd send in a bug report or something, but i doubt it would even get looked at lol.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question