Unknown C++ errors...

idNut

Diamond Member
Jun 9, 2002
3,219
0
0
I'm trying to write my interface and implement for the first time and it isn't working out. I have a class SavingsAccount in the .h with all the right functions and variables and I included this header file into the .cpp. I have SavingsAccount::fCalcMonthlySavings() { code} in the .cpp and fCalcMonthlySavings() is declared in the interface but it's giving me two errors pointing to this.

1.) overloaded function differs only by return type from 'void __thiscall SavingsAccount::fCalcMontlySavings(void)

2.) 'fCalcMonthlyInterest' : redefinition; different basic types.

Last question is, what are these called: SavingsAccount::fCalcMonthlySavings() { code }? I have no idea what their real name is, maybe someone can clue me in.

At this rate I'll never be a good programmer, I just suck ass period. I want to be a game programmer or designer but I can't see that anymore, I'm so discouraged with this complex alogrithm that I have no help or motivation anymore except John Carmack but he can't help me one on one. My instructor is getting sort of annoyed by me asking him so many questions so I'm going to lay off him. By the way, I'm 16 almost 17 if you're curious. I long to be in the entertainment business but I can't figure out what is right for me. I'm being stupid anymore and idolizing after people in there like John Carmack, Trent Reznor and all my other favorite artists or engineers. I dunno, I feel so hopeless, sad, and pathetic anymore.
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
Did you put 'void' as in: void fCalcMonthlySavings() in your declaration file (.h)? VC is very picky about declaration and implementation function sytax matching completely. If your declarations do match, then just post the code from both the .h and .cpp file here and we'll have a look.

Programming takes some patience and practise. Most programmers (myself included) are average programmers at best - and there's nothing wrong with that. Relax and try to understand the concepts behind the programs first. I think most of your mistakes are probably syntax related - and they will go away with practise.
 

Spydermag68

Platinum Member
Apr 5, 2002
2,616
99
91
I am a 7 year TPF (IBM 390 assembly) & C programmer just learning C++ and Java. It takes time to learn all the ins and outs of programming language. My advice it to take a notebook and make yourself a "Dictionary" of all of the projects that you have done so you have something to fall back on when you you are stuck. If you have done a linked-list then expand on it an make a doublely linked list or a tree. From a tree make a binary tree, a queue or a hash table. Ask you teacher what book he would recommend to get a better understanding the core C++. Right now I am working a PDP-8 simulator with each assembly instruction as it's own class. It is simple program but the C++ version is a lot easier to read that my old Pascal program.
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: idNut
I'm trying to write my interface and implement for the first time and it isn't working out. I have a class SavingsAccount in the .h with all the right functions and variables and I included this header file into the .cpp. I have SavingsAccount::fCalcMonthlySavings() { code} in the .cpp and fCalcMonthlySavings() is declared in the interface but it's giving me two errors pointing to this.

1.) overloaded function differs only by return type from 'void __thiscall SavingsAccount::fCalcMontlySavings(void)

2.) 'fCalcMonthlyInterest' : redefinition; different basic types.

As singh said, my guess is that there is some difference between your prototype for SavingsAccount::fCalcMontlySavings() function in the header file, and the implementation of the function in the .cpp file. From the sound of it, maybe your return value is not the same for both? Basically, the compiler doesn't see the prototype & the implementation as being for the same function, but it sees the same function name & arguments and thinks you may be trying to overload it.

Post the code (or at least relavent sections) and we may be able to give you a better read!

Last question is, what are these called: SavingsAccount::fCalcMonthlySavings() { code }? I have no idea what their real name is, maybe someone can clue me in.

Not quite sure what you're asking here?? fCalcMonthlySavings appears to be a member function of the SavingsAccount class. Looks like you are trying to refer to the implementation of this function?

At this rate I'll never be a good programmer, I just suck ass period. I want to be a game programmer or designer but I can't see that anymore,

I think its early in the game to come to that conclusion. The thing with programming, especially with a complex compiled language like C/C++ is that the initial learning curve is very steep. There are alot of little things that you have to get perfect initially to make any progress at all! I've spent hours just trying to get a new compiler to work, and I've been programming C for about 9 years! But once you figure that stuff out, you're on your way.

I'm so discouraged with this complex alogrithm that I have no help or motivation anymore except John Carmack but he can't help me one on one. My instructor is getting sort of annoyed by me asking him so many questions so I'm going to lay off him. By the way, I'm 16 almost 17 if you're curious. I long to be in the entertainment business but I can't figure out what is right for me. I'm being stupid anymore and idolizing after people in there like John Carmack, Trent Reznor and all my other favorite artists or engineers. I dunno, I feel so hopeless, sad, and pathetic anymore.

Ok, step away from the keyboard.
I mean it. You sound kinda burned out.
Go do something else for awhile. It's summer! And at 17, you can count the last of your free summers on one hand. Take advantage of it.