Showing posts with label CPP. Show all posts
Showing posts with label CPP. Show all posts
CPP
#include
using namespace std;
//create class
class Student{
public: // A.s
int id; //D.M
string nm; // D.M
//member function
void insert(int i, string n){
id=i;
nm=n;
}
void disp(){
cout<<"ID:"<
// Default Constructor Example
#include
using namespace std;
//create class
class Student{
public: // A.s
int id; //D.M
string nm; // D.M
//member function
void insert(){
cout<<"Enter ID & Name: ";
cin>>id>>nm;
}
void disp(){
cout<<"ID:"<
// Parametrized Constructor Example
#include
using namespace std;
//create class
class Student{
public:
int id;
string nm;
Student(int i, string n){
id=i;
nm=n;
}
void disp(){
cout<<"ID"<
agyanadda
January 24, 2019
Subscribe to:
Posts (Atom)