CPlusProject Learning

阅读更多

开发环境:Eclipse IDE for C/C++ Developers 

编译成功后,在Binaries ,run in local 后在控制台就可看到结果. 

 

 

https://www.w3schools.in/cplusplus-tutorial/inheritance/ 

 

 

//============================================================================
// Name        : CPlusProject.cpp
// Author      : William
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include 
using namespace std;

class Calc
 {

public:
  int val2;
  Calc(int x)
  {
   val2=x;
 }
};

class stud
{
    public:
    char name[30],clas[10];
    int rol,age;
    string myname;

    void enter()
    {
//        cout<<"Enter Student Name: "; cin>>name;
//        cout<<"Enter Student Age: "; cin>>age;
//        cout<<"Enter Student Roll number: "; cin>>rol;
//        cout<<"Enter Student Class: "; cin>>clas;

//    	cout<<"Enter Student Name: "; cin>>myname;
    }

    void display()
    {
        cout<<"\n Age\tName\tR.No.\tClass";
        cout<<"\n"<> roll;
        cout << "Enter the two highest marks: "; cin >> m1 >> m2;
    }
};
class extracurriculam {
protected:
    int xm;

public:
    void getsm()
    {
        cout << "\nEnter the mark for Extra Curriculam Activities: "; cin >> xm;
    }
};
class output : public studx, public extracurriculam {
    int tot, avg;

public:
    void display()
    {
        tot = (m1 + m2 + xm);
        avg = tot / 3;
        cout << "\n\n\tRoll No    : " << roll << "\n\tTotal      : " << tot;
        cout << "\n\tAverage    : " << avg;
    }
};


int main() {
//	std::cout<<"This is my first C++ Program.";
//	std::cout< a) {
		  cout << "\nb is greater" << endl;
	  }else{
		  cout << "\na is greater" << endl;
	  }

	  if(area > 3000){
		  cout << " 111" << endl;;
	  }else{
		  cout << " 222" << endl;;
	  }

	  int age[5]={2,25,30,32,35};
	  cout<<"\n " << age[1];
	  cout<<"\n sizeof: " << sizeof(age);
	  cout<<"\n sizeof: " << sizeof(age)/sizeof(age[0]);



	  for(int n=0;n 
  

 

 

你可能感兴趣的:(CPlusProject Learning)