c++ code help

Aug 19, 2015 at 9:33pm
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
Aug 19, 2015 at 9:45pm
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.
Aug 19, 2015 at 11:47pm
My class name is called Joust, I wanted to store a string called yellowknight, and print hello brandon
Aug 20, 2015 at 5:03am
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 Aug 21, 2015 at 1:47pm
Aug 20, 2015 at 9:22am
@Nybble There's a fairly obvious problem with your variable definition there...
Aug 21, 2015 at 1:47pm
lol, yeah I fixed it.
Topic archived. No new replies allowed.