c++ code help

Line 1 #include <iostream>
Line 2 #include <string>
Line 3 using namespace std;
Line 4 int main();
Line 5 class Joust
Line 6 {
Line 7 string "yellowknight";
Line 8 };
Line 9{
Line 10 printf("hello brandon");
Line 11 }

I get errors from this c++ code that says. Line 7 Expected member name or ; after declaration specifiers. Line 9 expected unqualified-id.

I'm not sure how to fix these 2 error's
I don't know what you intended to write, since almost none of that makes any sense. The best I can do is clean it up so it at least compiles and runs:
1
2
3
4
5
6
#include <cstdio>

int main()
{
    printf("hello brandon");
}
Review your literature on the basics of syntax and program structure.
My class name is called Joust, I wanted to store a string called yellowknight, and print hello brandon
Well "yellowknight" isn't a variable... Remove the quote signs on it and assign what ever you want to it. Ex std::string yellowknight = "yellowknight";
Last edited on
@Nybble There's a fairly obvious problem with your variable definition there...
lol, yeah I fixed it.
Topic archived. No new replies allowed.