私はその共通のLNK2019エラーがあり、何が間違っているのか理解できません。ここでLNK2019この場合の解決方法は?すべてが正しいと思われる
は私のソリューションエクスプローラである:ここで
は私Rectangle.cpp
次のとおりです。ここで
class Rectangle
{
public:
int getArea()
{
return this->width*this->height;
}
int width;
int height;
};
は私Rectangle.h
次のとおりです。ここで
#pragma once
class Rectangle
{
public:
int getArea();
int width;
int height;
};
は私Functions.cpp
次のとおりです。
#include <iostream>
#include "Rectangle.h";
using namespace std;
int main()
{
Rectangle r3{ 2, 3 };
cout << r3.getArea();
return 0;
}
私はC++にとって非常に新しく、正しく処理したようですが、まだエラーが発生しています。
なぜ、あなたはcppファイルで 'Rectangle'クラスを再定義していますか?これを見てください:https://stackoverflow.com/questions/9579930/separating-class-code-into-a-header-and-cpp-file – NathanOliver
彼は何のクラスですか? – ohidano
@hidano彼はクラスを意味します。私の答えを見てください! =) – gsamaras