Dogクラスには2つメンバーを与えました。
下二つ(参照とポインタ)がundefined reference to `Dog::ptrfunc(Dog const*)'
とエラーが出ています。
元々の例はstructだったのを、クラスにして書き換えたのですが誤りを見つけられません。
Dog doggy(150,"tilly");
doggy.valfunc(doggy);
doggy.ptrfunc(&doggy);
doggy.reffunc(doggy);
header
コード /* * Dog.cpp * * Created on: 2015/11/16 * Author: 礼央 */ #include<iostream> #include<string> #include"Dog.h" using namespace std; Dog::Dog(int color,string owner){ this->color=color; this->owner=owner; } void Dog::valfunc(Dog v1){ cout<<v1.color<<endl; cout<<v1.owner<<endl; } void ptrfunc(const Dog *p1){ cout<<p1->color<<endl; cout<<p1->owner<<endl; } void reffunc(const Dog &r1){ cout<<r1.color<<endl; cout<<r1.owner<<endl; } Dog::~Dog(){ cout<<"deconst"<<endl; }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/11/17 00:11
2015/11/17 00:23
2015/11/17 00:29