上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页
摘要: #include#include#include#include#define BUFSIZE 200int main(){ FILE *read_fp; char buffer[BUFSIZE+1];/*用于存放读取的内容*/ int chars_read; memset(buffer,'\0',sizeof(buffer)); read_fp=popen("uname -a","r");//用于显示内核版本 及现在时间 /*返回的是文件指针,因此-文件指针是要定义的*/ if(read_fp != NULL) { chars_r... 阅读全文
posted @ 2013-11-04 22:31 退之 阅读(1040) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 struct Student 8 { 9 int num;10 string name;11 char sex;12 int age;13 Student(int newnum,string newname,char newsex,int newage):num(newnum),name(newname),sex(newsex),age(age)14 {15 cout<<"Num: "<<num<... 阅读全文
posted @ 2013-11-04 20:18 退之 阅读(330) 评论(0) 推荐(0) 编辑
摘要: Linux下的在线播放神器:一个是Amarok缺点是,每个音乐源都要更新后才能播放。在一个就是中国造的:linux deepin下的深度音乐,缺点就是连不上。反正我是连不上 阅读全文
posted @ 2013-11-02 17:43 退之 阅读(285) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 using namespace std; 4 class Point 5 { 6 public: 7 Point(int x=0,int y=0):x(x),y(y){} 8 int getX() const {return x;} 9 int getY() const {return y;}10 private:11 int x,y;12 };13 int main()14 {15 Point a(4,5);16 Point * p1=&a;17 18 int (Point::*funcPtr)() c... 阅读全文
posted @ 2013-11-02 15:18 退之 阅读(174) 评论(0) 推荐(0) 编辑
摘要: //6-13#includeusing namespace std;class Point{public: Point(int x=0,int y=0):x(x),y(y){} int getX() const {return x;} int getY() const {return y;}private: int x,y;};int main(){ Point a(4,5); Point * p1=&a; int (Point::*funcPtr)() const=&Point::getX; cout*funcPtr)()getX() 2 //... 阅读全文
posted @ 2013-11-02 15:18 退之 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 using namespace std; 4 5 void printStuff(float data) 6 { 7 cout<<"this is the print stuff function."<<endl; 8 } 9 10 void printMessage(float data)11 {12 cout<<"the data to be listed is"<<data<<endl;13 }14 15 void printFloat(float data) 阅读全文
posted @ 2013-11-02 15:17 退之 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 using namespace std; 4 5 void splitFloat(float x,int * intPart,float * fracPart) 6 { 7 *intPart=static_cast(x); 8 *fracPart=x-*intPart; 9 }10 11 12 int main()13 {14 cout>x;20 splitFloat(x,&n,&f);21 cout<<"Inter Part="<<n<<"Fraction Part=&quo 阅读全文
posted @ 2013-11-02 15:13 退之 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 using namespace std; 4 5 6 int main() 7 { 8 int i; 9 int *ptr=&i;10 i=10;11 cout<<"i="<<i<<endl;12 cout<<"*ptr="<<*ptr<<endl;13 14 return 0;15 } 阅读全文
posted @ 2013-11-02 15:12 退之 阅读(143) 评论(0) 推荐(0) 编辑
摘要: //在weight.h中#ifndef _WEIGHT_H_#define _WEIGHT_H_class Car;class Boat{ private: double weight; public: Boat(double w=0.0):weight(w){} double getWeight(){return weight;} friend double getTotalWeight(Car & m,Boat & n);};class Car{ private: double weight; p... 阅读全文
posted @ 2013-11-02 15:10 退之 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 int main() 4 { 5 int line1[]={1,0,0}; 6 int line2[]={1,0,0}; 7 int line3[]={1,0,0}; 8 9 int * pLine[3]={line1,line2,line3};10 11 std::cout<<"Matrix test:"<<std::endl;12 13 14 for(int i=0;i<3;++i)15 for(int j=0;j<3;j++)16 std::cout<<pLine[... 阅读全文
posted @ 2013-11-02 15:10 退之 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 using namespace std; 4 5 class A 6 { 7 public: 8 A(int i); 9 void print();10 private:11 const int a;12 static const int b=10;13 };14 15 16 A::A(int i):a(i){}17 18 void A::print()19 {20 cout<<a<<":"<<b<<endl;21 }22 //常成员函数只能通过初始化来获得初值23 24 int main()25 阅读全文
posted @ 2013-11-02 15:09 退之 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 using namespace std; 4 5 class A 6 { 7 private: 8 int x,y; 9 public:10 A(int i,int j):x(i),y(j){}11 void Adisplay() const12 {13 cout<<"x="<<x<<" "<<"y="<<y<<endl;14 }15 };16 17 int main()18 {19 const A a(5,4);20 a.Adisp 阅读全文
posted @ 2013-11-02 15:08 退之 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 using namespace std; 4 5 class Point 6 { 7 public: 8 Point(int x=0,int y=0):x(x),y(y){} 9 int getX() const {return x;}10 int getY() const {return y;}11 private:12 int x,y;13 };14 int main()15 {16 Point a(4,5);17 Point *p1;p1=&a;18 cout<<(*p1).getX()<<end... 阅读全文
posted @ 2013-11-02 15:08 退之 阅读(150) 评论(0) 推荐(0) 编辑
摘要: //在weight.h中#ifndef _WEIGHT_H_#define _WEIGHT_H_class Point{public: Point(int x=0,int y=0):x(x),y(y){} int getX(){return x;} int getY(){return y;} friend float dist(Point &p1,Point &p2) { double x=p1.x-p2.x; double y=p1.y-p2.y; return static_cast(sqrt(x*x+y*y)); }private: ... 阅读全文
posted @ 2013-11-02 15:07 退之 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 class Point 4 { 5 public: 6 Point(int xx=0,int yy=0) 7 { 8 x=xx; 9 y=yy;10 cout<<"Constructor is called"<<endl;11 }12 Point(Point &p);13 int getX()14 {15 return x;16 }17 int getY()18 {19 ... 阅读全文
posted @ 2013-11-02 15:04 退之 阅读(273) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页