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

x
?
Solved

Function not being added to header file.

Posted on 2004-08-09
8
Medium Priority
?
285 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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

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

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