Answer to Question #194216 in C++ for Root

Question #194216

http://prnt.sc/130efe5


1
Expert's answer
2021-05-17T03:36:35-0400
#include <iostream>
using namespace std;
class course
{
	int courseNumber;
	int creditHours;
public:
	void setCourse(int x, int y);
};
 
void course::setCourse(int x, int y)
{
	courseNumber = x;
	creditHours = y;
}
 
class section
{
	int secNumber;
	course c;	// composition
public:
	void setSection(int, int, int);
};
 
void section::setSection(int x, int y, int z)
{
	c.setCourse(x, y);
	secNumber = z;
}
 
int main()
{
	section obj[7];
	for (int i = 1; i < 8; i++)
	{
		obj[i-1].setSection(117, 3, i);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS