Error C2039 help

Working on a project for school and I having this error. I am trying to call a public function of this class. I do not know what to look for to fix this problem. I have checked the spelling. I have also used the "Find references" function in the ide and the ide was able to find the function declaration and definition and call.

What else should I be looking for?



EDIT: Added most of source.cpp did not include all of it due to length restrictions. The header file and implementation file will be included below.

Edit #2 Removed my code
Last edited on
If you show us the code someone might be able to spot the problem.
Also, please post the exact text of the error message.

The compiler thinks you're trying to reference something that is not a member of the class.
https://msdn.microsoft.com/en-us/library/fdwb3fd7.aspx
I am actually getting the same error 3 times and those error messages are as follows:


Error C2039 'newAccountRate': is not a member of 'CCdAccount'
Error C2039 'newAccountDuration': is not a member of 'CCdAccount'
Error C2039 'newAccountDeposit': is not a member of 'CCdAccount'

These three errors are all in Source.cpp (which is now in the first post) on lines 207 209 212.

I removed some code for space concerns I don't think what I removed is related.


CdAccount class header file

Edit Removed my code
Last edited on
And what happens if you put code in those functions?

Functions that don't alter the values of member variables should be marked const.
Just tried to add a cout statement as a placeholder and tried to compile. Still received the same error.

As far as marking functions that do not change member variables. Originally I had the arrays of the class objects passed to the various functions marked as const. I ran into the issue of not knowing the syntax to run some the accessor member functions as const. Is it as simple as [code] const float CCdAccount::getDeposit()[/const]?

I want to get everything working correctly before I go over and make sure that the prompts match what is expected. I copy & pasted portions from previous projects in the class so I am fairly certain that there are prompt errors as a result.
Is it as simple as [code] const float CCdAccount::getDeposit()[/const]?


The correct synthax is float CCdAccount::getDeposit() const, but don't worry too much about it. First you need to get your program compilled.

I am a bit puzzled where the problem is. Your CCdAccount.cpp and CCdAccount.h compile fine with my VS 2015 CE. What compiler / IDE do you use ?
I copy & pasted portions from previous projects in the class so I am fairly certain that there are prompt errors as a result.


Did you copy and paste into the header file? I've seen this "function is not a member of class" error come up where a starting framework for a class was copied from one source to a different computer, and new functions then added in - the compiler didn't recognize the new functions.

It looked fine in Visual Studio, but when copied into a text editor there was a definite difference between the older code and newer code (line break and then different indentation IIRC). Creating a new header file, retyping the same code (no cut and paste), and replacing the old header with new header in the project worked in that case.
The ide I am using is visual studio 2017.

The three functions I am having problems with were not were not copy and pasted. I typed the declaration into the header file then had VS create the definition for me.

When I get back to my computer later I will delete every thing (the 3 problem functions) and try again. If the dose t work I will install another ide and try it there.

Thanks for the help guys will update later
I ended up fixing the problem by saving my source and header files. Deleting the project and starting a new one then pulling in the files again.

After I did all that I saw that the 3 functions I was having problems with were not saved in the files i saved, despite showing up in Visual Studio when I opened the project.

Thanks for the help
Topic archived. No new replies allowed.