Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ template class Program 3) Run the following Sample Code - Produce the correct output and Turn it in for credit // Sample Class -

C++ template class

Program 3) Run the following Sample Code - Produce the correct output and Turn it in for credit

// Sample Class - Print and Study, RUN the code...

#include

#include

using namespace std;

// STEP 1 - DEFINE THE new datatype/Class 'aThing'

class aThing {

public: // Public means that is can be access in step 3 with the dot notation

double getWeight(void) { return weight; } // public functions accessible by dot notation

void setWeight( double inWeight ) { weight = inWeight; }

private: // Private means that it can NOT be accessed with the dot notation, but indirectly with a public function

double weight; // private variables only accessible by a function

};

int main()

{ // STEP 2 - DECLARATION - USE the new datatype/class 'aThing' in a Declaration statement to create 'ThingOne'.

aThing ThingOne;

// STEP 3 - Use the OBJECT defined in step 2 - With dot notation

ThingOne.setWeight(110);

cout << "Use Function/Method get Weight - "<< "Weight is: " << ThingOne.getWeight() << endl;

system("PAUSE"); // MAC User comment this line out.

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

What is Ramayana, who is its creator, why was Ramayana written?

Answered: 1 week ago

Question

To solve by the graphical methods 2x +3y = 9 9x - 8y = 10

Answered: 1 week ago