Hi, Im working with making my first class and I have everything set up but when i try to build, i get the apparently "famous" c2011 error. I've tried different methods of solving this problem after searching online, but nothing worked.
Here is my code
This code creates the gradebook object
This is my header file.Code:// #include "stdafx.h" #include <iostream> #include "gradebook.h" //this is the header file for my class using namespace std; int main() { Gradebook mygradebook ("CS 101") ; // }
This is my .cpp file, for the header,Code:#include "stdafx.h" #include <iostream> #include <string> using namespace std; class Gradebook { public: Gradebook (string name); void Setname(string name); string Getname(); void DisplayMessage( ); private : string Coursename ; };
The error i get isCode:#include "stdafx.h" #include "gradebook.h" #include <string> using namespace std; class Gradebook { public: Gradebook::Gradebook (string name){ //constructor statement Setname(name); } void Gradebook::Setname(string name) { // Mutator method Coursename = name; } string Gradebook::Getname() { return Coursename ; } void Gradebook::DisplayMessage( ){ //display message statement cout << "Welcome To The Gradebook For " << Getname() << endl ; } private: string Coursename ; };
I've tried using the #indef, endif, method but i wasnt exactly sure how to use that and it didnt work outCode:gradebook.cpp(11) error C2011: 'Gradebook' : 'class' type redefinition gradebook.h(8) : see declaration of 'Gradebook'Can someone help me out here???



LinkBack URL
About LinkBacks
Can someone help me out here??? 



