SlideShare a Scribd company logo
1 of 2
Download to read offline
Create another four objects, this time, using the new operator, one object per constructor, and on
each object call the print function.
#include
#include
using namespace std;
class Employee
{
private:
int id;
string name;
short age;
public:
Employee() : id(7700), name("Luke Skywalker"), age(29) {}
Employee(int emp_id) : id(emp_id), name("Indiana Jones"), age(80) {}
Employee(int emp_id, string emp_name) : id(emp_id), name(emp_name), age(29) {}
Employee(int emp_id, string emp_name, short emp_age) : id(emp_id), name(emp_name),
age(emp_age) {}
void print()
{
cout << "Employee ID: " << id << endl;
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
}
};
int main()
{
Employee emp1;
emp1.print();
Employee emp2(99134);
emp2.print();
Employee emp3(7700, "Steven Bradshaw");
emp3.print();
Employee emp4(2187, "Mike Tyson", 56);
emp4.print();
return 0;
}
OUTPUT:
Employee ID: 7700
Name: Luke Skywalker
Age: 29
Employee ID: 99134
Name: Indiana Jones
Age: 80
Employee ID: 7700
Name: Steven Bradshaw
Age: 29
Employee ID: 2187
Name: Mike Tyson
Age: 56

More Related Content

Similar to Create another four objects, this time, using the new operator, one .pdf

Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdf
rajkumarm401
 
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdfThis code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
aamousnowov
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
fashioncollection2
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
Rahul04August
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3
Mohamed Ahmed
 

Similar to Create another four objects, this time, using the new operator, one .pdf (14)

TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Graphql, REST and Apollo
Graphql, REST and ApolloGraphql, REST and Apollo
Graphql, REST and Apollo
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdf
 
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdfThis code has nine errors- but I don't know how to solve it- Please gi (1).pdf
This code has nine errors- but I don't know how to solve it- Please gi (1).pdf
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScript
 
Madrid gug - sacando partido a las transformaciones ast de groovy
Madrid gug - sacando partido a las transformaciones ast de groovyMadrid gug - sacando partido a las transformaciones ast de groovy
Madrid gug - sacando partido a las transformaciones ast de groovy
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
 
Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node js
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
java
javajava
java
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy Annotations
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3
 

More from info48697

Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdfDefine or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
info48697
 
Data Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdfData Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdf
info48697
 
Donita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdfDonita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdf
info48697
 
DO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdfDO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdf
info48697
 

More from info48697 (20)

Define the terms adulteration and misbranding How are these concept.pdf
Define the terms adulteration and misbranding How are these concept.pdfDefine the terms adulteration and misbranding How are these concept.pdf
Define the terms adulteration and misbranding How are these concept.pdf
 
Define medical futility. Does the definition of futility change with.pdf
Define medical futility. Does the definition of futility change with.pdfDefine medical futility. Does the definition of futility change with.pdf
Define medical futility. Does the definition of futility change with.pdf
 
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdfDefine or explain CHAPTER 7 � Types of Tangible and Intan.pdf
Define or explain CHAPTER 7 � Types of Tangible and Intan.pdf
 
Define and explain social entrepreneurship Describe the corporate pu.pdf
Define and explain social entrepreneurship Describe the corporate pu.pdfDefine and explain social entrepreneurship Describe the corporate pu.pdf
Define and explain social entrepreneurship Describe the corporate pu.pdf
 
Define divisors(x) as {y Z y x}. Let a and b be two integers. Pr.pdf
Define divisors(x) as {y  Z y  x}. Let a and b be two integers. Pr.pdfDefine divisors(x) as {y  Z y  x}. Let a and b be two integers. Pr.pdf
Define divisors(x) as {y Z y x}. Let a and b be two integers. Pr.pdf
 
Define artificial intelligence. What does it mean to say that artifi.pdf
Define artificial intelligence. What does it mean to say that artifi.pdfDefine artificial intelligence. What does it mean to say that artifi.pdf
Define artificial intelligence. What does it mean to say that artifi.pdf
 
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdf
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdfCualquier resultado, resultado o elemento medible, tangible y verifi.pdf
Cualquier resultado, resultado o elemento medible, tangible y verifi.pdf
 
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdfDaniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
Daniel, Steven ve Chris CTde m�hendis olarak �almaktadr. irketlerin.pdf
 
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdfCuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
Cuando un auditor descubre m�s de una condici�n que requiere la desv.pdf
 
De cara al futuro, creo que la importancia subyacente de la educaci�.pdf
De cara al futuro, creo que la importancia subyacente de la educaci�.pdfDe cara al futuro, creo que la importancia subyacente de la educaci�.pdf
De cara al futuro, creo que la importancia subyacente de la educaci�.pdf
 
david and liam have entered into a limited partnership where david i.pdf
david and liam have entered into a limited partnership where david i.pdfdavid and liam have entered into a limited partnership where david i.pdf
david and liam have entered into a limited partnership where david i.pdf
 
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdfDave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
Dave borrowed $1,150 on January 1, 2022. The bank charged him a $4.5.pdf
 
Data Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdfData Security Read the article below and answer the following questi.pdf
Data Security Read the article below and answer the following questi.pdf
 
Daniel Browning Smith has been named the most flexible man alive. Sm.pdf
Daniel Browning Smith has been named the most flexible man alive. Sm.pdfDaniel Browning Smith has been named the most flexible man alive. Sm.pdf
Daniel Browning Smith has been named the most flexible man alive. Sm.pdf
 
d. What is the total value of the company as of year 0 e. What is.pdf
d. What is the total value of the company as of year 0 e. What is.pdfd. What is the total value of the company as of year 0 e. What is.pdf
d. What is the total value of the company as of year 0 e. What is.pdf
 
D) good genes ^^^ Which of the following isare example(s) of as.pdf
D) good genes ^^^ Which of the following isare example(s) of as.pdfD) good genes ^^^ Which of the following isare example(s) of as.pdf
D) good genes ^^^ Which of the following isare example(s) of as.pdf
 
Donita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdfDonita Murphy is a primary care physician at a local community pract.pdf
Donita Murphy is a primary care physician at a local community pract.pdf
 
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdfDolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
Dolphin Co., 2017 ylnda 1.500 $ �cret ald ve bunun 13� 2018de kaz.pdf
 
Do you agree with how countries in this part of the world have been .pdf
Do you agree with how countries in this part of the world have been .pdfDo you agree with how countries in this part of the world have been .pdf
Do you agree with how countries in this part of the world have been .pdf
 
DO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdfDO NOT use System.exit().DO NOT add the project or package stateme.pdf
DO NOT use System.exit().DO NOT add the project or package stateme.pdf
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 

Create another four objects, this time, using the new operator, one .pdf

  • 1. Create another four objects, this time, using the new operator, one object per constructor, and on each object call the print function. #include #include using namespace std; class Employee { private: int id; string name; short age; public: Employee() : id(7700), name("Luke Skywalker"), age(29) {} Employee(int emp_id) : id(emp_id), name("Indiana Jones"), age(80) {} Employee(int emp_id, string emp_name) : id(emp_id), name(emp_name), age(29) {} Employee(int emp_id, string emp_name, short emp_age) : id(emp_id), name(emp_name), age(emp_age) {} void print() { cout << "Employee ID: " << id << endl; cout << "Name: " << name << endl; cout << "Age: " << age << endl; } }; int main() { Employee emp1; emp1.print(); Employee emp2(99134); emp2.print();
  • 2. Employee emp3(7700, "Steven Bradshaw"); emp3.print(); Employee emp4(2187, "Mike Tyson", 56); emp4.print(); return 0; } OUTPUT: Employee ID: 7700 Name: Luke Skywalker Age: 29 Employee ID: 99134 Name: Indiana Jones Age: 80 Employee ID: 7700 Name: Steven Bradshaw Age: 29 Employee ID: 2187 Name: Mike Tyson Age: 56