注册 登录
编程论坛 VC++/MFC

在类中定义了成员函数,但是为什么说找不到标识符呢?

AntorDragon 发布于 2014-10-03 17:40, 3739 次点击
如图,编译器是vc2008 ,嗯,说找不到标识符,但是我明明在类中定义了呀?为什么?
#include<iostream>
using namespace std;

class Point
{
//private:
    //int x,y;
public:
    int x,y;
    Point(int a=0,int b=0)   //构造函数,默认参数,没有返回值
    {
        x=a;
        y=b;

    }
    Point(Point& p)
    {
        x=p.x;
        y=p.y;
    }
    void fun1(Point p)
    {   
         cout<<p.x<<p.y<<endl;
         
    }
};
void main()
{
  cout<<"please input x y"<<endl;
  Point p1(10,20);
  //Point(*p1);
  fun1(p1);

  
}
1 回复
#2
天使梦魔2014-10-03 18:32
使用指针符号   .   或者引用符号   ->    来制定那个fun1是谁的成员,因为你外部同样可以定义一个全局函数
1