Msd
#include <iostream> #include <string> using namespace std; class student{ protected: string name, gender, grade; int age; public: void get() { cout << "Enter the name of The student : "; getline (cin, name); cout << "Enter the age of the student : "; cin >> age; cout <<"Enter the gender of The student : "; cin >> gender; cout << "Enter the grade of the student : "; cin >> grade; } }; class general public student{ protected: string stream; int mark; public: void get1() { cout << "Enter the stream of the student : "; getline (cin, stream); cout<<"Enter the mark of the student : "; cin >> mark; } void print (){ cout << endl; cout << "Name" << name <<endl; cout << "age: << age <<endl; cout << "gender: " << gender << endl; cout << "stream: " << stream << endl; cout << "mark: " <<mark << endl; cout << "grade: " << grade << endl; }; int main() general obj; obj.get(); obj.get1(); obj.print(); return 0; }
Msd
In derived class Getline (cin, stream); Is not accepting from users just displaying and skip to next step Why this happening please say anyone
Msd
remained newline on input stream ?
I can't share pic otherwise I will show It showing like Enter the stream of the student : Enter the mark of the student : In stream it's not asking user to enter just showing and goes to next step
\Device\NUL
See my dp
No pm plz
Msd
No pm plz
Ok bro I will
Msd
But it is in the derived class
Msd
It won't work ?
Msd
Maybe because of protected keyword ?
But for name it's working in base class
Bobur
Guys could you help me with this one ?
Bobur
A is an integer vector of 5 elements, A[0], A[1],,, A[4]. Assign different integer values to the 5 elements, print A components. int A[]= {3, 5,,,,,} can be used. Calculate average of the five elements.
Aman
Can anyone plzz Send me the syntax of Switch statement
Aman
No i want the authentic one i m unable to find
Dima
lol
Robert
So funny
Robert
What's the authentic one
the best for everyone
klimi
yes
who are "them"?
Dima
authentic switch lmao gotta make a book and call it like that
Bereket
class Book { private: string title; string author; int pages; public: Book(string title, string author, int pages) { title = title; author = author; pages = pages; }; string gettitle() { return title; }; string getauthor() { return author; }; int getpages() { return pages; }; void print() { cout << "title " << gettitle() << endl; cout << "author " << getauthor() << endl; cout << "pages " << getpages() << endl; }; }; int main() { Book harrypotter("harry potter", "jk.rowling", 200); Book dertogada("dertogada", "Yismake Worku", 300); harrypotter.print(); }
Abdulwahab
I was having an error, the code hasn't run, can someone please help me to rectify the error?
Abdulwahab
I was having an error, the code hasn't run, can someone please help me to rectify the error?
} /* A program to calculate the sum of even numbers and odd numbers from 1 to 10*/ #include <iostream> int main() { int sumOfEven; int sumOfOdd; for(int i=1; i <= 10; i++) { if(i % 2 == 0) { sumOfEven += 1; } else { sumOfOdd += 1; } } cout<<"Sum of even number = " <<sumOfEven<<endl; cout<<"Sum of odd number = " <<sumOfOdd<<endl; return (0); }
Артем
And don't forget about std
Abdulwahab
And don't forget about std
Ohh 👍 -Using namespace Std;
Артем
Or just std::cout, etc.
Dima
ye, using namespace std is bad
Dima
get used to it
Abdulwahab
Or just std::cout, etc.
It is better to write "using namespace std; once and for all.
\Device\NUL
#nousingstd
レッギ
Dima
don't you dare to post it again
Abdulwahab
Thank you sir
the best for everyone
who are "them"?
see the code up this message
the best for everyone
what is the mistake in it
the best for everyone
someone told me I cant use this argument with c language
the best for everyone
so what could I use or the mistake
Grigoriy
Hello. Help please. I make public inheritance but place inherited members in protected section. Is this wrong? Is this allowed by c++ standards?
Grigoriy
class TObserver { public: virtual void notify(void) = 0; }; class TWorkerImpl : public TObserver // public, not protected!!! { protected: virtual void notify(void) override {} public: void doWork1(void) {}; void doWork2(void) {}; };
Grigoriy
I have to use public inheritance because of shared pointers
Maruthi
Can anyone share c language course
Maruthi
I am a beginner Any internship aslo Please help me
Anonymous
char FPS[] = "FPS"; sprintf(FPS, "%d FPS", GetFPS());
Anonymous
is there any better way to do this?
Anonymous
getfps returns an integer
klimi
is there any better way to do this?
I am not sire but doesn't this create just 4 char array?
Joo
#include <iostream> #include <string> #include <vector> using namespace std; struct Pair { string name; double val; }; vector<Pair>pairs; double& value(const string& s){ for(int i=0; i<pairs.size(); i++) if(s==pairs[i].name) return pairs[i].val; Pair p={s,0}; pairs.push_back(p); return pairs[pairs.size()-1].val; } int main(){ string buf; while(cin>>buf) { value(buf)++; } for(vector<Pair>::const_iterator p=pairs.begin(); p!=pairs.end(); ++p){ cout<<p->name<<": "<<p->val<<'\n'; } return 0; }
Joo
Can someone help me with this code
Joo
It is stuck on the while loop
Joo
Also, If someone could explain the value function to me I would be glad
Anonymous
moyo
/warn
Anonymous
Hello guys
klimi
Hello guys
Are you crypto scammer?
Anonymous
Are you crypto scammer?
No way, as well mime how you talk
Anonymous
I need someone to do a job for me ??
Sarmat
Guys, can you please help me. I need a something like a tutorial or a practice work to improve my std library skills. Some video, like creating messenger on c++, or creating application, or smth like this.
klimi
I need someone to do a job for me ??
We generally don't allow job advertisements here
klimi
No way, as well mime how you talk
Mime how I talk? .... Sorry but you have PFP that scammers like to have, you have only one name and your bio says "talk only about crypto"... You are just suspicious
Anonymous
We generally don't allow job advertisements here
I’m not advertising job. I’m offering a job. Got some issue that needed a programmer to solve it
Anonymous
If anyone can work of blockchain development We can work together
Mohamed Ahmed
cout << +!!!!"2";
Mohamed Ahmed
why the output will be 1 ??
\Device\NUL
why the output will be 1 ??
You are using ! for address pointed by "2"
\Device\NUL
Since the address it's not zero then !!!0 !!1 !0 1
\Device\NUL
like this const char *str = "2" std::cout << !!!!str ;