I am getting these errors when running my code: Artist.cpp:28:9: error: no declaration matches ‘void Artist::printInfo() const’ 28 | void Artist::printInfo() const{ | ^~~~~~ Artist.cpp:28:9: note: no functions named ‘void Artist::printInfo() const’ In file included from Artist.cpp:1: Artist.h:7:7: note: ‘class Artist’ defined here 7 | class Artist{ | ^~~~~~ Artwork.cpp:22:9: error: no declaration matches ‘void Artwork::printInfo()’ 22 | void Artwork::printInfo(){ | ^~~~~~~ Artwork.cpp:22:9: note: no functions named ‘void Artwork::printInfo()’ In file included from Artwork.cpp:2: Artwork.h:8:7: note: ‘class Artwork’ defined here 8 | class Artwork{ | ^~~~~~~ Artist.cpp code: #include "Artist.h" #include #include using namespace std; Artist::Artist(){ artistName = "None"; birthYear = 0; deathYear = 0; } Artist::Artist(string artistName, int birthYear, int deathYear){ this->artistName = artistName; this->birthYear = birthYear; this->deathYear = deathYear; } string Artist::GetName() const{ return artistName; } int Artist::GetBirthYear() const{ return birthYear; } int Artist::GetDeathYear() const{ return deathYear; } void Artist::printInfo() const{ cout << "Artist: " << artistName; if (deathYear != 1 ) cout << " ( " << birthYear << " - " << deathYear << " ) " << endl; else cout << ", born " << birthYear << endl; } Artist.h code: #ifndef ARTISTH #define ARTISTH #include using namespace std; class Artist{ public: Artist(); Artist(string artistName, int birthYear, int deathYear); string GetName() const; int GetBirthYear() const; int GetDeathYear() const; void PrintInfo() const; private: string artistName; int birthYear; int deathYear; }; #endif
I am getting these errors when running my code:
Artist.cpp:28:9: error: no declaration matches ‘void Artist::printInfo() const’ 28 | void Artist::printInfo() const{ | ^~~~~~ Artist.cpp:28:9: note: no functions named ‘void Artist::printInfo() const’ In file included from Artist.cpp:1: Artist.h:7:7: note: ‘class Artist’ defined here 7 | class Artist{ | ^~~~~~ Artwork.cpp:22:9: error: no declaration matches ‘void Artwork::printInfo()’ 22 | void Artwork::printInfo(){ | ^~~~~~~ Artwork.cpp:22:9: note: no functions named ‘void Artwork::printInfo()’ In file included from Artwork.cpp:2: Artwork.h:8:7: note: ‘class Artwork’ defined here 8 | class Artwork{ | ^~~~~~~
Artist.cpp code:
#include "Artist.h"
#include <iostream>
#include <string>
using namespace std;
Artist::Artist(){
artistName = "None";
birthYear = 0;
deathYear = 0;
}
Artist::Artist(string artistName, int birthYear, int deathYear){
this->artistName = artistName;
this->birthYear = birthYear;
this->deathYear = deathYear;
}
string Artist::GetName() const{
return artistName;
}
int Artist::GetBirthYear() const{
return birthYear;
}
int Artist::GetDeathYear() const{
return deathYear;
}
void Artist::printInfo() const{
cout << "Artist: " << artistName;
if (deathYear != 1 )
cout << " ( " << birthYear << " - " << deathYear << " ) " << endl;
else
cout << ", born " << birthYear << endl;
}
Artist.h code:
#ifndef ARTISTH
#define ARTISTH
#include <string>
using namespace std;
class Artist{
public:
Artist();
Artist(string artistName, int birthYear, int deathYear);
string GetName() const;
int GetBirthYear() const;
int GetDeathYear() const;
void PrintInfo() const;
private:
string artistName;
int birthYear;
int deathYear;
};
#endif
Trending now
This is a popular solution!
Step by step
Solved in 2 steps