Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Function not being added to header file.

Posted on 2004-08-09
Medium Priority
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?
Question by:Monstrosity_
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
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.

Author Comment

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 ;)

Author Comment

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

--------------------Configuration: classes - Win32 Debug--------------------
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 {}


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 39

Expert Comment

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



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

Regards, Alex

LVL 39

Expert Comment

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



Regards, Alex


Author Comment

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

Accepted Solution

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.

Author Comment

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.

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

618 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