Class and Object

 avatar
narendra
c_cpp
a month ago
379 B
11
Indexable
#include <iostream>
using namespace std;

class Fruit{
  public :
 string name;
 string color;
  
};

int main(){
  
  Fruit apple;
  apple.name = "Apple";
  apple.color="Rad";
  cout <<apple.name<<"-"<<apple.color<<endl;
   
   Fruit*mango= new Fruit();
   mango->name="Mango";
   mango->color="Yellow ";
   cout<<mango->name<<"-"<<mango->color<<endl;
   
   
    return 0;
}


Leave a Comment