SlideShare a Scribd company logo
1 of 1
Download to read offline
I am trying to create a program that will create Objects of different array sizes.
The main program inputs a charactor and two coordinates. It then attempts to identify what sort
of object it needs to return. If it is an O, it will create an array of size one with the number 1 in it.
I Cannot change main in any way. I don't know how to create an array and return it as t1. can
someome help me?
Thanks
int main(){
Shape *t1, *t2;
cin>>ch >>x >>y;
t1 = Shape :: makeshape(ch, x, y);
}
//I am working on defination of makeshape
Shape *makeShape( char ch, int posx, int posy)}{
if(char=='O'){
O array = new O[1];
return O;
} //or do I need a pointer here?
}
Solution
Yup you can return an array . But , you have to do some modification. In the function
makeShape , you have specified Shape class object to be the return type. But, you are sending
array so you need to change the return type. And, it would effiecient if you send a pointer.
Then,one can get dynamic memory . But, answer for your question is yes ; you just need to
change the return type of the function.

More Related Content

Similar to I am trying to create a program that will create Objects of differen.pdf

April 4, 2014
April 4, 2014April 4, 2014
April 4, 2014
khyps13
 
computer notes - Stack
computer notes - Stackcomputer notes - Stack
computer notes - Stack
ecomputernotes
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guide
ThalaAjith33
 
Excel formulas-manual
Excel formulas-manualExcel formulas-manual
Excel formulas-manual
srv1972
 
Hi there I am having difficulty in finalizing my Tetris game , below.pdf
Hi there I am having difficulty in finalizing my Tetris game , below.pdfHi there I am having difficulty in finalizing my Tetris game , below.pdf
Hi there I am having difficulty in finalizing my Tetris game , below.pdf
fonecomp
 

Similar to I am trying to create a program that will create Objects of differen.pdf (20)

April 4, 2014
April 4, 2014April 4, 2014
April 4, 2014
 
Exponential-Function.pptx general Mathematics
Exponential-Function.pptx general MathematicsExponential-Function.pptx general Mathematics
Exponential-Function.pptx general Mathematics
 
computer notes - Stack
computer notes - Stackcomputer notes - Stack
computer notes - Stack
 
Analysing simple pendulum using matlab
Analysing simple pendulum using matlabAnalysing simple pendulum using matlab
Analysing simple pendulum using matlab
 
N Queen Problem using Branch And Bound - GeeksforGeeks.pdf
N Queen Problem using Branch And Bound - GeeksforGeeks.pdfN Queen Problem using Branch And Bound - GeeksforGeeks.pdf
N Queen Problem using Branch And Bound - GeeksforGeeks.pdf
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
CONSIDER THE INTERVAL [0, ). FOR EACH NUMERICAL VALUE BELOW, IS IT IN THE INT...
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
Machine learning
Machine learningMachine learning
Machine learning
 
Tema 1 funciones
Tema 1 funcionesTema 1 funciones
Tema 1 funciones
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1
 
Maple
MapleMaple
Maple
 
Lec2
Lec2Lec2
Lec2
 
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guide
 
Excel formulas-manual
Excel formulas-manualExcel formulas-manual
Excel formulas-manual
 
Hi there I am having difficulty in finalizing my Tetris game , below.pdf
Hi there I am having difficulty in finalizing my Tetris game , below.pdfHi there I am having difficulty in finalizing my Tetris game , below.pdf
Hi there I am having difficulty in finalizing my Tetris game , below.pdf
 
CAP776Numpy (2).ppt
CAP776Numpy (2).pptCAP776Numpy (2).ppt
CAP776Numpy (2).ppt
 

More from formicreation

Many people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdfMany people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdf
formicreation
 
Know the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdfKnow the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdf
formicreation
 
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdfIPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
formicreation
 
Description For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdfDescription For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdf
formicreation
 
Discuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdfDiscuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdf
formicreation
 
B. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdfB. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdf
formicreation
 
Any ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdfAny ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdf
formicreation
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 

More from formicreation (20)

Many people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdfMany people believe that, because the emergence of life was very impr.pdf
Many people believe that, because the emergence of life was very impr.pdf
 
Know the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdfKnow the different types of viruses which have a dsRNA genome A type .pdf
Know the different types of viruses which have a dsRNA genome A type .pdf
 
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdfIssued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
Issued a $4000 Note Receivable for 3 months 10 interest. Calculate .pdf
 
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdfIPv4 provided the primary addressing scheme in TCPIP. However after.pdf
IPv4 provided the primary addressing scheme in TCPIP. However after.pdf
 
Implement the member function void insertAfterHead(int d) of the Lin.pdf
Implement the member function void insertAfterHead(int d) of the Lin.pdfImplement the member function void insertAfterHead(int d) of the Lin.pdf
Implement the member function void insertAfterHead(int d) of the Lin.pdf
 
How does Ansoffs matrix impact organizations missionsSoluti.pdf
How does Ansoffs matrix impact organizations missionsSoluti.pdfHow does Ansoffs matrix impact organizations missionsSoluti.pdf
How does Ansoffs matrix impact organizations missionsSoluti.pdf
 
How is a chorioallantoic placenta different from a choriovitelline.pdf
How is a chorioallantoic placenta different from a choriovitelline.pdfHow is a chorioallantoic placenta different from a choriovitelline.pdf
How is a chorioallantoic placenta different from a choriovitelline.pdf
 
How can I tell when it is going to be a Archimedean Spiral. What is .pdf
How can I tell when it is going to be a Archimedean Spiral. What is .pdfHow can I tell when it is going to be a Archimedean Spiral. What is .pdf
How can I tell when it is going to be a Archimedean Spiral. What is .pdf
 
flow chart or step by step process of the key steps in forming a uni.pdf
flow chart or step by step process of the key steps in forming a uni.pdfflow chart or step by step process of the key steps in forming a uni.pdf
flow chart or step by step process of the key steps in forming a uni.pdf
 
Description For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdfDescription For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdf
 
Discuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdfDiscuss one (1) traditional and two (2) new strategies that special i.pdf
Discuss one (1) traditional and two (2) new strategies that special i.pdf
 
Define health systems and healthcare delivery systems and discuss th.pdf
Define health systems and healthcare delivery systems and discuss th.pdfDefine health systems and healthcare delivery systems and discuss th.pdf
Define health systems and healthcare delivery systems and discuss th.pdf
 
B. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdfB. You do an experiment in which you divide 8 cell stage urch.pdf
B. You do an experiment in which you divide 8 cell stage urch.pdf
 
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdfa. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
a. project aid. b. emergency aid. c. development aid. d. bilateral ai.pdf
 
An electron is moving in a circular motion clockwise. A uniform magne.pdf
An electron is moving in a circular motion clockwise. A uniform magne.pdfAn electron is moving in a circular motion clockwise. A uniform magne.pdf
An electron is moving in a circular motion clockwise. A uniform magne.pdf
 
After reading Thomas Malthus population theory and the ideas of Ju.pdf
After reading Thomas Malthus population theory and the ideas of Ju.pdfAfter reading Thomas Malthus population theory and the ideas of Ju.pdf
After reading Thomas Malthus population theory and the ideas of Ju.pdf
 
Any ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdfAny ideas on an IT topic I could use for this case studyFor this .pdf
Any ideas on an IT topic I could use for this case studyFor this .pdf
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
C++ Write a function that takes a number as a parameter and display.pdf
C++ Write a function that takes a number as a parameter and display.pdfC++ Write a function that takes a number as a parameter and display.pdf
C++ Write a function that takes a number as a parameter and display.pdf
 
Why is it important for marketers to understand the product life cyc.pdf
Why is it important for marketers to understand the product life cyc.pdfWhy is it important for marketers to understand the product life cyc.pdf
Why is it important for marketers to understand the product life cyc.pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

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.
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
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
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
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...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
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
 
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
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
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
 

I am trying to create a program that will create Objects of differen.pdf

  • 1. I am trying to create a program that will create Objects of different array sizes. The main program inputs a charactor and two coordinates. It then attempts to identify what sort of object it needs to return. If it is an O, it will create an array of size one with the number 1 in it. I Cannot change main in any way. I don't know how to create an array and return it as t1. can someome help me? Thanks int main(){ Shape *t1, *t2; cin>>ch >>x >>y; t1 = Shape :: makeshape(ch, x, y); } //I am working on defination of makeshape Shape *makeShape( char ch, int posx, int posy)}{ if(char=='O'){ O array = new O[1]; return O; } //or do I need a pointer here? } Solution Yup you can return an array . But , you have to do some modification. In the function makeShape , you have specified Shape class object to be the return type. But, you are sending array so you need to change the return type. And, it would effiecient if you send a pointer. Then,one can get dynamic memory . But, answer for your question is yes ; you just need to change the return type of the function.