write a class TV that contain attribute of Brand Name, Model & Retail Price | write a constructor of TV class to initialize all attribute |Write a method to display all attribute and a method to change the attribute
Write a class TV that contain attribute of Brand Name, Model & Retail Price. write a constructor of TV class to initialize all attribute. Write a method to display all attribute and a method to change the attribute.
Program Source Code:
#include<iostream>
#include<string.h>
using namespace std;
class TV{
private:
float price;
char BrandName[20], TvModel[15];
public:
TV(char b[],char m[],float p){
strcpy(BrandName,b);
strcpy(TvModel,m);
price = p;
}
void ChangeValue(char b[],char m[],float p){
strcpy(BrandName,b);
strcpy(TvModel,m);
price = p;
}
void display(){
cout<<"Model Name is:"<<TvModel<<endl;
cout<<"Brand Name is:"<<BrandName<<endl;
cout<<"Tv Price is :"<<price<<endl;
}
};
main(){
TV t("Hair","STDV",30000);
cout<<"--------TV Object Value----------"<<endl;
t.display();
t.ChangeValue("Sony","HDTV",25000);
cout<<"--------After Change TV Object Value----------"<<endl;
t.display();
}
Output:
Post a Comment