Very simple C++ question. Basically why doesn't this work:
#include
u have to include the braces {
Netbeans has cout << "Hello there" << endl; in red underlined and it says "unexpected token cout. unable to resolve identifier cout"
hey there's a computer science group, you may post your question there this group is only for math questions
u have to have the curly braces and also include void main ()
Oh I see. Is there a reason why I need void main(){}?
Tomas.A: I thought I was in the computer science group. Sorry, after this question I will go there.
I mean what is the reason
you can go straight away and i am sure agdwnwngo would help you
void main () is the part wherein the computer understands that the program has to be executed from that place the curly brace after that is where it starts execution from till the time the curly brace ends
Ok so even in procedural programming, we use that, right?
c++ is object orientated language
but it has c features so it can be procedural to my knowledge
i just don't know what that means in practice.
it has some modified terms and it has to be followed
it will be object orientated anyway but you can write code without using object (only main)
Also: #include <iostream> int void main() { int num = 5; int *numPointer = # //cout << &numPointer << endl; cout << "Hello there" << endl; return 0; } doesn't work: "Unable to resolve identifier cout". I am using netbeans.
using namespace std;
but java is fully object-oriented and i can write code just using the main method. but a lot of things have to be static afterwards. is that a difference between java and c++?
i meant int main() not int void main()
so you can do same thing in c++ too
you can write code just using main in c++ as in java
i'm not saying you can't in C++. I'm just asking if you're forced in Java to use static and in C++ you're not.
if you code all in main and use no objects that is.
idk im not very familiar with c++
o me neither. the real reason why i asked this question in the first place is to test the following:
#include <iostream>; using namespace std; int main() { int num = 5; // int *numPointer = # // Way 1 string str = # cout << str << endl; // Way 2 // cout << &num << endl; // cout << "Hello there" << endl; return 0; }
Way 2 works as expected but way 1 doesn't.
ask in computer science group and u will get answer lol
i don't know pointers
Alright, thanks still.
(I asked it there)
Join our real-time social learning platform and learn together with your friends!