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
Solved

Function not being added to header file.

Posted on 2004-08-09
8
265 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_
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

828 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