|
Very good explanation, thank you !
|
|
|
|
|
c++, how to make an array program one dimension from( 1 to 7 numbers)that the user insert these numbers in terminal that finally display sum,average,GPA,grade,min and max. please help me
|
|
|
|
|
No, sorry, we don't do people's homework here. This is very basic stuff, and any C/C++ reference should be able to help you. If you try things, and get stuck on a particular issue, then come back and ask.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
Alma28 wrote: c++, how to make an array program one dimension from( 1 to 7 numbers)that the user insert these numbers in terminal that finally display sum,average,GPA,grade,min and max. please help me
Your problems are problems only to very beginners and the solution is in the very first steps of learning the language.
If you want to learn C/C++ :
Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]
C++ Programing Language[^]
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Good Morning Sir,
I referred this tutorial, Embedding Python program in a C/C++ code[^]
I have followed up the tutorial and successfully embedded Python in my code.
PyRun_SimpleString("print('Hello World from Embedded Python!!!')");
is used to execute a single line of Python code but how do I run a multiple lines of code in Python. I also tried running a Python from a file but the file also needed to be there for running the executable. I dont want a file along with my executable, I searched in the google sir but I find no results.
I am confused here, I dont know what to do
Thank you sir for your time
|
|
|
|
|
Ask this question right under that post and author will tell you how. There is a forum provided for questions about methodology of the article, or similar aspects etc.
That is, so that if someone else happens to have a similar problem, they can know how to solve this.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thank you sir I have posted the question below the article 
|
|
|
|
|
Hi,I had a question about class and object memory, any hints are welcome.
1) Is the class occupies some memory? as I understand it, class is just a data type as int, long ,double.
2) Is the member function in the Object's memory ? I mean, in the sizeof(object).
3) The derived class object inherited from base class, the base class has member functions, then is the member function memory layout be inherited to the derived class object?
Thanks
|
|
|
|
|
- No a class is like a template or blueprint, and just contains the definitions used by the compiler to generate the code that construct objects.
- No, member functions exist in a separate part of the application's address space, they are not part of the object.
- No, all member functions will be present in memory and invoked as required by the running application.
For more details consult your reference guide or the documentation on MSDN.
|
|
|
|
|
Thanks.
Then in the inheritance operation, for example:
class A {
public:
void funct() { cout << "a" << endl; }
}
};
Class B:protected A {
private:
void funct() { cout << "b" << endl; }
};
int main()
{
B c;
b.funct();
;
return 0;
}
B's funct() can hide A's funct(), if I comment funct()in Class B, b.funct() will call funct() in class A.
Seems like b inherited the function in class A.
Since member function only has one copy in memory, then how can B inherit the member function from A?
|
|
|
|
|
Like I said before, both functions will be in memory, so either or both of them can be called. Overriding and hiding affects how the compiler will invoke the functions, it does not affect how the code exists in memory.
|
|
|
|
|
Thank you for your reply.
I am a little confused about the inheritance, member function inheritance.
So the member function of one class, only has one copy in the memory map, then if class B's base class is class A,
the inheritance mechanism makes the B's object has member variables of class A.
and B's object inherited the member functions of class A,while B's object don't have those functions, B's object just know how to invoke those functions, right?
And the member function inheritance follow same inheritance rule as member variables, for example, private inheritance will make all member functions inherited from base class A, turn to private in class B.
class A {
public: void f1(){}
protected: int f2() {}
private: char f3() {}
};
class B:private A {
// B inherit f1(), f2(), f3(), and access for all 3 functions will be private.
};
Thanks
}
|
|
|
|
|
You have the general idea. All methods of all classes will be available in memory. The actual method being called at any time is controlled according to the inheritance rules; see Inheritance (C++)[^].
|
|
|
|
|
thanks, so both functions will has only one copy in memory. but compiler decide overriding and hiding effects, right?
|
|
|
|
|
Correct the selection is done via a Virtual Method Table (VMT) and now you have got the concept this will make sense
Virtual method table - Wikipedia[^]
In vino veritas
|
|
|
|
|
|
See if this is of any help - Polymorphism in C[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
Hi
I am getting the above error, and I know its a programmer trainee error but I can't for the life of me figure it out
I did a find all from Visual Studio (looking in my solution directory) and what found was
the function was defined once
I did declare it ending with ';'
And when I call it or the declaration or the actual routine all have the same parameter list
Here is the result of the find all
line 43 is the declaration line 1606 is the actual function line 1743 is where it actually used
, Subfolders, Find Results 1, "quot;"
cpu.c(43):void hex_to_ascii(BYTE *ipx, char *str, int num);
cpu.c(1606): void hex_to_ascii(BYTE *ipx, char *str, int num)
cpu.c(1743): hex_to_ascii(ipx,str,num);
hmacros.h(182): hmacros.h(187): cpu.c(43) : see previous definition of 'hex_to_ascii'
Matching files: 3 Total files searched: 764
|
|
|
|
|
"Matching files:3" but I only see two distinct file names... do you have cpu.c included in the project twice somehow?
|
|
|
|
|
That's not it I checked only once the other was the output (compiler output) file
|
|
|
|
|
Well, there are very few things that could cause this... an actual redefinition or a namespace conflict. To test if it's a namespace conflict, wrap the function in a namespace and recompile, if it gives you the same error, you have a redefinition in that same file somehow. I can't tell you exactly how without looking at your code and your project/makefile.
edit: You can also check namespace conflict by changing your function name temporarily (just to see if that's it).
|
|
|
|
|
I just recompile that file seems like the compiler doesn't like function definition
but there is nothing wrong with it. I don't have hex_to_acii anywhere in the file
void hex_to_ascii(BYTE *ipx, char *str, int num) <-- line 1607
{ <- line 1606
BYTE inst;
int i;
char *holdstr;
and got this compile error message
(1607): error C2084: function 'void hex_to_ascii(BYTE *,char *,int)' already has a body
1> d:\cpu.c(1606) : see previous definition of 'hex_to_ascii'
|
|
|
|
|
ForNow wrote: I don't have hex_to_acii anywhere in the file
...and then you proceed to show me how you have hex_to_ascii defined... 
|
|
|
|
|
I meant just that one area
I am not sure how make a namespace in C
Besides from compiler message it seems like it doesn't like the way I declared the function in the file
Maybe I'll rename it or move it to a different area in the file
|
|
|
|
|
Thought you were doing C++... in that case, change the name of the function and see if the error persists.
|
|
|
|