You are on page 1of 2

// First need to define Advertising struct

#include<iostream>
using namespace std;
namespace struct_adver
{

struct Advertising struct nestStruct //Nested structure


{ {
private: char name[5];
static int val; struct Advertising ad1;
int adsShown;
int clkAds; int getdata()
double CTRP; {
double TE; cout<<"Call from Nested Structure:"<<endl;
ad1.getdata();
public: cout<<"\n Enter the Name:"<<endl;
int getdata() cin>>name;
{ val++;
return 0;
cout<<"Enter the values"<<endl; }
cin>>adsShown;
cin>>clkAds; int display()
val++; {
return 0; cout<<"Display from Nested Structure:"<<endl;
} ad1.process();
ad1.display();
int process() cout<<"\n Name:"<<name<<endl;
{
CTRP = double(clkAds)/double(adsShown))*100; return 0;
TE = double(adsShown) * (CTRP/100) * 2.0; }
return 0; };
}
} ------------------------------------------------------------------------
int display() ********************************************
{

cout<<"The values:"<<endl;
cout<<"CTRP:"<<CTRP<<endl;
cout<<"TE:"<<TE<<endl;
cout<<Advertising::val<<endl;
cout<<"val now:"<<val<<endl;
return 0;
}
};
#include<iostream>
#include "struct2.h"
using namespace struct_adver;
using namespace std;

int Advertising::val;

int main()
{
nestStruct nst1, nst2; // structure declaration

nst1.getdata();
nst1.display();

nst2.getdata();
nst2.display();

return 0;
}

You might also like