-
I don't understand your intentions, so you probably want to use polymorphism.
I'll guess your intentions, and if you have questions, you can follow them up.
class picture
virtual void draw();
class point : public picturevoid draw();
class line: public picturevoid draw();
class circle: public picturevoid draw();
Picture is the base class, which is the father of Point Line Circle. There is a method called draw for the base class, but the content of the draw of each subclass is different, so each subclass must write its own draw, and the base class cannot be generalized.
In order to implement polymorphism, you need to add a virtualtask to the draw of the base class, which can be written like this.
void task(picture *pic)pic->draw();
At this time, if the object you pass in is a point, it will call the point's own draw method (this is polymorphism, if you don't add virtual, it will call the draw method of the base class picture).
At this point, the task can accept the point line circle polymorphism, which is the pointer of the parent class to get a reference to the object of the child class.
-
There are 3 functions overloaded in graphics.
respectively. task(point)
task(line)
task(circle)
In this way, when the function is called, the corresponding function will be called according to different input parameters.
-
The upstairs intentions and explanations all make sense.
About constructor initialization: you buy a new house and have to decorate it before you move in; Similarly, some of your variables need to be manipulated before they can be used (if you don't initialize, the original memory unit is indeterminate, so if you don't write a constructor, the compiler will have a default constructor that assigns all variables to 0 or null; It will be different in different languages), but you can also assign values to variables as you wish. But the constructor can do more than just assign values, as long as you want it to do, you can write it into it; The compiler will execute the constructor first every time the class is executed.
It's nothing special either.
In addition, the virtual machine group is on the product**, which is super cheap.
-
1. First of all, open the programming software and enter the source code of C language to test.
2. Let it output the number of the first int type, but this is not clear.
3. Next, use the while loop to let it output the input string.
4. After completion, compile. Then, after the press enter is executed, you can see the output parameter information, indicating that the program has successfully obtained the parameters.
-
The parameters of the main function can be assigned by the command line or shortcuts, such as some programs attach the -window parameter is the window to run, most programs can be run without parameters, it mainly depends on how the program is written, the receiving parameters generally only accept an array of strings, and the element values of the array are arranged in order according to the input parameters.
-
I'll just talk about how it works!!
Convert the ** file you have compiled (let's name it as a compilation and connect it to an executable file, enter the current directory in DOS mode, and run it in the following format.
Parameter 1 Parameter 2 ...Parameter n
-
How to run:
Let's say your program is.
Open the Command Prompt:
Go to your directory and enter the following command:
a basdfsa 1314324 -k -f carriage return will run.
In this case, it is defined in the main function.
argc = 6 in int main(int argc, char *args) means that there are six parameters, corresponding to args[0] ="";
args[1] = "a";
args[2] = "basdfsa";
args[3] = "1314324";
args[4] = "-k";
args[5] = "-f";
That's it.
-
As you run, just enter the parameters.
-
If it's not possible to access the variables inside the function, you can just put the main function in a class and declare it public. Use this variable in the main function, which can be accessed anywhere, and then declare the variable you want to use in this class, note that it should be static. This allows access in other classes.
Of course, the functions that want to access these variables can also be in the same class.
-
Why do you want to access the variables of the main() function directly? You can pass it through the parameters!
using systme;
using ; >>>More
The friend function should be described in a class in the form of: >>>More
Just modify it directly.
Global variables are visible globally, as well as within local functions. >>>More
Material Tools: Excel2010
1. Open excel2010**, take the following data as an example, if the student's score is above the average score, it is qualified, if it is below the average score, it is unqualified; >>>More
It's textbox, right? textbook?
double somedouble; >>>More