Click here to Skip to main content
15,920,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in basic i can write
10 let H=head
20 let H=H+1
30 print H

What I have tried:

how would this be coded in c++
Posted
Updated 23-Dec-19 20:16pm

1 solution

That has nothing to do with .CPP or .H files; they do not have equivalents in Basic where the source is stored in a single file.
And the C++ code for your basic is trivial:
C++
#include <iostream>

using namespace std;
#define HEAD 666;
int main()
{
    int h = HEAD;
    h = h + 1;
    cout << h;
    return 0;
}
 
Share this answer
 
Comments
Member 14670586 24-Dec-19 2:36am    
It may seenm trivial but is your simple and very clear code place in HEAD.cpp or in HEAD.h?
OriginalGriff 24-Dec-19 3:45am    
.CPP contains the code, .H is header files which do not contain code, just definitions.
Like maybe
#define HEAD 666
or
const int HEAD = 666
would be in .H so it's "shared" by every file that needs it.

Do yourself a favour, and get a book (or better a course) on C++ - just asking random questions and trying to pick it up as you go along is not the best way to learn, or even close. And from a BASIC standpoint? A very bad idea indeed - forget everything you know about BASIC and start from scratch or you will get confused.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900