Getdata c
![getdata c++ getdata c++](https://photos1.blogger.com/x/blogger/3402/1340/1600/824654/urlremoval_blogpost7.png)
Add the STAThreadAttribute to your application's Main method. Per->getdata() // Get the data from the user.įor(int i=0 iputdata() // Print the required output for each object.The current thread is not in single-threaded apartment (STA) mode. If val is 1 current object is of type ProfessorĮlse per = new Student // Else the current object is of type Student Constraints :Ĭout>n //The number of objects that is going to be created. If the first line of input for each object is 2, it means that the object is of the Student class, you will have to input the name, age and the marks of the student in 6 subjects. If the first line of input for each object is 1, it means that the object being created is of the Professor class, you will have to input the name, age and publications of the professor. The first line of input contains the number of objects that are being created. Note: Expand the main function to look at how the input is being handled. You can create more data members if you want. Solve this problem using virtual functions, constructors and static variables. The function putdata should print the name, age, sum of the marks and the cur_id of the student.įor each object being created of the Professor or the Student class, sequential id’s should be assigned to them starting from 1. The function getdata should get the input from the user: the name, age, and the marks of the student in 6 subjects. It has two member functions: getdata and putdata. The class Student should have two data members: marks, which is an array of size 6 and cur_id. The function putdata should print the name, age, publications and the cur_id of the professor. The function getdata should get the input from the user: the name, age and publications of the professor. There will be two member functions: getdata and putdata. The class Professor should have two integer members: publications and cur_id. The classes Professor and Student should inherit from the class Person. The class Person should have data members name and age. Create three classes Person, Professor and Student.
![getdata c++ getdata c++](https://media.geeksforgeeks.org/wp-content/uploads/20211028224555/Screenshot259.png)
This problem is to get you familiar with virtual functions. Virtual Functions in C++ – Hacker Rank Solution Problem Bjarne Stroustrup is known as the founder of C++ language.
Getdata c++ code#
The basic syntax and code structure of both C and C++ are the same.Ĭ++ programming language was developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph), located in U.S.A. It is an imperative and a compiled language.Ĭ++ is a middle-level language rendering it the advantage of programming low-level (drivers, kernels) and even higher-level applications (games, GUI, desktop apps etc.). Introduction To C++Ĭ++ is a general-purpose programming language that was developed as an enhancement of the C language to include object-oriented paradigm. Use These Option to Get Any Random Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use “Ctrl+F” To Find Any Questions Answer. If you are not able to solve any problem, then you can take help from our Blog/website. We are providing the correct and tested solutions of coding problems present on HackerRank. In this post, you will find the solution for Virtual Functions in C++-HackerRank Problem. This will highlight you profile to the recruiters. And after solving maximum problems, you will be getting stars. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language C++.