Statements and Flow--range-based for loop

Line 8 does not compile for me.

 
  string str {"Hello!"};


I tried changing the curly brackets to parentheses and it compiled but then the next line didn't.

I am using Codeblocks 10.05 for my IDE. Later versions did not download a compiler, not sure why (Windows 7 64 bit SP1).

Also, my compiler finds errors but doesn't give me hints as to what the problem is. Until this time I was able to figure out the problems on my own.
Thank you!
hjf
Last edited on
Also, my compiler finds errors but doesn't give me hints as to what the problem is.

What? If your compiler finds errors it reports what the errors are.

I tried changing the curly brackets to parentheses and it compiled but then the next line didn't.

What next line?

I followed the tutorial exactly for installation. Perhaps I have to check some things in order for the compiler to provide error reports. Right now all I get is a red square by a faulty line. I would like to know how to get error reports.

The next line is

for (char c : str)
You need to compile the code in order for the compiler to generate the error/warning messages.

There is nothing wrong, syntactically with that line, as long as you're using a C++11 or higher compatible compiler compiling in C++11 or higher mode.

Last edited on
Okay. I click on compiler every time and that is what gives me the red square. I have figured out everything on my own until now. I will try to find out what version of compiler compatibility I have. The person who suggested these tutorials said they would work fine with something lower than C++11 but perhaps that has changed over time. The lab I will be working in uses an older version of C++ so he thought I might as well use the version that the lab uses. But I want to keep using the tutorials so I will upgrade if I need to.

So, to make sure, the Hello line in my first post is correct with curly brackets if I have a C++11 compatible compiler?

edit:I checked. the compiler is not compatible with C++11.
Last edited on
Topic archived. No new replies allowed.