Alright everyone I am pretty new to programming in C++. I have being doing it for college for about 2 months now. I send my professor a copy of one of my programs to help me understand the different parts of it. He told me the program I have submitted would require a constructor. With that said my knowledge on constructors is they must have the same name as the class in the program. So could anyone explain to me what my constructor is in my program. Thank you
#include <iostream>
#include <string>
using namespace std;
class Vertebrae { //here i am declaring my class as Vertebrae
private: //here i am setting a private access modifier
string brain; //creating the string brain as a private attribute
string backbone; //creating the string backbone as a private attribute
string skeleton; //creating the string skeleton as a private attribute
public: //setting my public access modifier
void setBrain(string a) {
brain = a;
}
string getBrain() {
return brain;
}
void setBackbone(string b) {
backbone = b;
}
string getBackbone(){
return backbone;
}
void setSkeleton(string c) {
skeleton = c;
}
string getSkeleton() {
return skeleton;
}
};
int main(){
Vertebrae A;
Vertebrae B;
Vertebrae C;
A.setBrain("Brains");
B.setBackbone("Spines");
C.setSkeleton("Boney Skeletons");
cout << "Vertebrates have " << A.getBrain(); //outputting the first definition of a vertebrae
cout << ", "; //outputting a comma
cout << B.getBackbone(); //outputting the second definition of a vertebrae
cout << ", and "; //outputting another comma and the word and
cout << C.getSkeleton(); //outputting the third definition of a vertebrae
return 0;
}