#ifndef TEXT_H
#define TEXT_H
usingnamespace std;
class Text{
public:
Text();
void SetText(string font, int size, string color, string data);
void GetParameters(); //Obviously I cant use VOID cause I want to return values, but not sure what to use as it has strings and integers.
void PrintText();
private:
string font;
int size;
string color;
string data;
};
#endif // TEXT_H
#include <iostream>
#include "Text.h"
#include "Box.h"
#include "Text.h"
usingnamespace std;
Text::Text(){
}
void Text::SetText(string font, int size, string color, string data){
font = font;
size = size;
color = color;
data = data;
}
void Text::GetParameters (){ //How would I return these values? SO i can use them in PrintText as seen below.
}
void Text::PrintText(){
cout <<"Text parameters are: " <<GetParameters() <<endl;
}
Any pointers are greatly appreciated at this point.
Heres the assignment that was assigned to give some context:
Realize class Text with parameters font, size, color, data.
The following classes of Text methods should be implemented:
constructor
SetText
GetKatrsParameter
PrintText // Output Values Output
Must implement Box with parameters width, height, border_color.
The following classroom methods should be implemented:
constructor
SetBox
GetKatrsParameter
PrintBox // parameter value output
TextBox should be derived from the Text and Box classes.
The following TextBox methods should be implemented:
constructor
SetTextBox
PrintTextBox (parameter value output)
Write a program that illustrates the work of the acquired structure. Display the GetKatrsParameter function calls from the TextBox class.
there are 2 simple ways.
1
void foo (int &x, string &s) //passed by reference
{
s = "doh"; //whatever was passed in for them was changed. its 'returned' to the caller this way.
x = 3;
}
2
a user defined type.
myclass foo(inputs){returns a myclass object which contains the stuff you wanted}
you can also use class variables for your specific example. if you set a class member variable in text::getparams, it will be changed and readable down in text::print -- they behave much like global variables so long as you are in the text:: scope. This type of data feels like it should be private without any external access; its data you only use inside the class and the user does not need to know about it (? guessing).