Asad
it all defends! for example, i cannot do kernel with c. but, others can... staff like that. language is just a tool. more specific question is whether YOU can do something with c or c++ or whatever. language itself is able to do nothing...
꧁༒☬kim☬༒꧂
# include <iostream>
# include <string.h>
# include <stdlib.h>
using namespace std;
class student
{
protected:
string firstname, secondname, thirdname, regNo, email,course;
double YOS;
int telNo;
public:
void setparameters(string m, string n, string o,string p,string q, string t, double r,int s)
{
firstname=m;
secondname=n;
thirdname=o;
regNo=p;
email=q;
course=t;
YOS=r;
telNo=s;
}
virtual void output()
{
}
};
class GIS : public student
{
void output()
{
system("cls");
cout<<"\nName:\t\t"<<firstname<<" "<<secondname<<" "<<thirdname<<endl;
cout<<"Reg-No:\t\t"<<regNo<<endl;
cout<<"E-mail:\t\t"<<email<<endl;
cout<<"Tel-No:\t\t"<<telNo<<endl;
cout<<"Course:\t\t"<<course<<endl;
cout<<"Y.O.S:\t\t"<<YOS<<endl<<endl<<endl;
}
};
class GEGIS : public student
{
void output()
{
system("cls");
cout<<"\nName:\t\t"<<firstname<<" "<<secondname<<" "<<thirdname<<endl;
cout<<"Reg-No:\t\t"<<regNo<<endl;
cout<<"E-mail:\t\t"<<email<<endl;
cout<<"Tel-No:\t\t"<<telNo<<endl;
cout<<"Course:\t\t"<<course<<endl;
cout<<"Y.O.S:\t\t"<<YOS<<endl<<endl<<endl;
}
};
class TELECOMMUNICATION ENGINEERING : public student
{
void output()
{
system("cls");
cout<<"\nName:\t\t"<<firstname<<" "<<secondname<<" "<<thirdname<<endl;
cout<<"Reg-No:\t\t"<<regNo<<endl;
cout<<"E-mail:\t\t"<<email<<endl;
cout<<"Tel-No:\t\t"<<telNo<<endl;
cout<<"Course:\t\t"<<course<<endl;
cout<<"Y.O.S:\t\t"<<YOS<<endl<<endl<<endl;
}
};
int main()
{
student S1;
GIS st1;
GEGIS st2;
TELECOMMUNICATION ENGINEERING st3;
student *ptr1= &st1;
student *ptr2= &st2;
student *ptr3= &st3;
student *ptr3= &S1;
string a,b,c,d,e,f;
int g,option;
double h;
system("color 0a");
cout<<"________________________________________________________"<<endl;
cout<<"COLLEGE OF ENGINEERING AND TECHNOLOGY"<<endl;
cout<<"________________________________________________________"<<endl;
cout<<"\n1. GEGIS\n2. GIS\n3. TELECOMMUNICATION ENGINEERING\n\n Choose your option::";
cin>>option;
cout<<"\n\n________________________________________________________"<<endl;
if(option==1)
{
system("cls");
cout<<"\n________________________________________________________"<<endl;
cout<<"GEOMATICS ENGINEERING AND GEOSPATIAL INFORMATION SYSTEMS"<<endl;
cout<<"\n________________________________________________________"<<endl;
cout<<"Firstname::";
cin>>a;
cout<<"Secondname::";
cin>>b;
cout<<"Lastname::";
cin>>c;
cout<<"Registration No::";
cin>>d;
cout<<"E-mail::";
cin>>e;
cout<<"Tel-No::";
cin>>g;
cout<<"Course::";
cin>>f;
cout<<"Y.O.S::";
cin>>h;
cout<<"\n\n________________________________________________________"<<endl;
cout<<"Record done"<<endl;
ptr2->setparameters(a,b,c,d,e,f,h,g);
ptr2->output();
}
else if(option==2)
{
system("cls");
cout<<"________________________________________________________"<<endl;
cout<<"\t GEOSPATIAL INFORMATION SYSTEMS"<<endl;
cout<<"________________________________________________________"<<endl;
cout<<"Firstname::";
cin>>a;
cout<<"Secondname::";
cin>>b;
cout<<"Lastname::";
cin>>c;
cout<<"Registration No::";
cin>>d;
cout<<"E-mail::";
cin>>e;
cout<<"Tel-No::";
cin>>g;
cout<<"Course::";
cin>>f;
cout<<"Y.O.S::";
cin>>h;
cout<<"\n\n________________________________________________________"<<endl;
cout<<"Record done"<<endl;
ptr1->setparameters(a,b,c,d,e,f,h,g);
ptr1->output();
}
if(option==3)
{
system("cls");
cout<<"\n________________________________________________________"<<endl;
cout<<"TELECOMMUNICATION ENGINEERING"<<endl;
cout<<"\n_______________________________________________________
꧁༒☬kim☬༒꧂
"<<endl;
cout<<"Firstname::";
cin>>a;
cout<<"Secondname::";
cin>>b;
cout<<"Lastname::";
cin>>c;
cout<<"Registration No::";
cin>>d;
cout<<"E-mail::";
cin>>e;
cout<<"Tel-No::";
cin>>g;
cout<<"Course::";
cin>>f;
cout<<"Y.O.S::";
cin>>h;
cout<<"\n\n________________________________________________________"<<endl;
cout<<"Record done"<<endl;
ptr3->setparameters(a,b,c,d,e,f,h,g);
ptr3->output();
}
else
{
cout<<"Error!! Wrong input.";
}
return 0;
}
...
fact is, if you got a significant more efficient algorithm to solve a certain problem, it will impact your performance way more than "using c or c++"
gallo
Sorry for my question, I want to open a file and write on with C++, but the file is in a folder protected by password, any ideas?
Anonymous
so i have a main class and a subclass , in each class i have 2 sifferent pointers , i create a destructor for main class , should i create a destructor for subclass ?
Рома
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 50
int main()
{
struct personality
{
char surname[SIZE];
char name[SIZE];
int day;
int month;
int year;
int marks[5];
double average;
struct personality *next;
};
struct personality *PZ11;
FILE* fp = fopen("list.txt", "r");
int countStuds;
int symbol; int i = 0;
do {
fscanf(fp, "%s %s", &PZ11->surname, &PZ11->name);
fscanf(fp, "%d %d %d", &PZ11->day, &PZ11->month, &PZ11->year);
for (int j = 0; j < 5; j++)
fscanf(fp, "%i", &PZ11->marks[j]);
i++;
} while (!feof(fp));
fclose(fp);
countStuds = i;
for (int i = 0; i < countStuds; i++)
{
printf("|");
printf("%12s %10s \n", PZ11->surname, PZ11->name);
++i;
}