pointer.cpp
来自「一个指针的例子,C++语言,我在初学C++时写的,大家请多指教」· C++ 代码 · 共 34 行
CPP
34 行
// Pointer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
#include "date.h"
#include "point.h"
int main(int argc, char* argv[])
{
// 对象数组
date days[10];
// this指针
cout<<date::today().add_year(8).add_month(23).string_rep()<<endl;
cout<<date::today().string_rep()<<endl;
//指向类成员的指针
Point pt(3,4);
cout<<pt.cal_dist(Point(0,0))<<endl;
int Point::*px;
px=&Point::x;
cout<<"x is : "<<pt.*px<<endl;
int *p=&pt.x;
cout<<"x is : "<<*p<<endl;
float (Point::*pdist)(Point&);
pdist=&Point::cal_dist;
cout<<(pt.*pdist)(Point(10,11))<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?