University of Cambridge >  Engineering Department >  computing help >  Languages >  C++

C++ FAQ

Contents

Here are some answers to C++-related questions commonly asked at CUED. If you can think of questions that should be added here, mail Tim Love

Compiling

  1. Nothing's working anymore. Files aren't compiling, and when I try to save source code the files are empty. What do I do?
  2. What are the most common bugs?
  3. What do the compiler's error messages mean?
  4. I get an error message saying "error: reference to 'count' is ambiguous" followed by lots of jargon. What's wrong?
  5. I get an error message saying that "The left side of '=' must be a modifiable lvalue" or "error: non-lvalue in assignment". What's a modifiable lvalue?
  6. I get a warning message saying "suggest parentheses around assignment used as truth value". Is that anything to worry about?
  7. I get a warning message saying " warning: control reaches end of non-void function". Is that anything to worry about?
  8. What does "error: name lookup of `i' changed for new ISO `for' scoping" mean?
  9. I get a warning message saying something about 'using namespace std;'

Executing

  1. My code compiles ok but it's not doing the right things - lines are being ignored etc
  2. My code compiles ok but when I run it nothing happens. What do I do?
  3. What are 'nan' and 'inf'?
  4. When I compile with geany there are no error messages but it doesn't let me run the program. What's wrong?

Language features

  1. I'm confused about commas and semi-colons
  2. What is an array?
  3. What is a structure?
  4. What is casting?
  5. How can I add one to a variable i?
  6. How can I write my own functions?
  7. What's the difference between "call by reference" and "call by value"?
  8. I want to create an array with a size the user types in. Can I do int i; cin >> i ; int array[i];?
  9. How do I convert from a number to a string?
  10. What does return 0; do at the end of the main function? new
  11. What are header files? What are they for? What does using namespace std; mean? new
  12. How do I convert from a string to a number?
  13. How do I convert a character to a string?

CUED-specific issues

  1. I've forgotten my handout. Are there any spares? new
  2. When I run graphics programs I get "freeglut (glue): Unable to create direct context rendering for window 'GLUE' This may hurt performance. freeglut (glue): Unable to create direct context rendering for window 'GLUI' This may hurt performance.". What do I do?
  3. [1AC++] Why doesn't the PlotNormal.cc Example compile?
  4. [1AC++] Can I work away from the DPO?
  5. [1AC++] Can I work from the command line?

General

  1. Why is C++ so hard?
  2. Why is the 1A C++ handout so long?

1A Mich Term

  1. How do random numbers work?
  2. I'm trying to do the exercises on my machine at home. It doesn't recognise random(). What shall I do?
  3. I don't understand how to count things and store the frequencies in an array new

1A Lent Term

  1. Why hasn't my score shown up in the trading league tables?
  2. I want to have ModelData data as a parameter to my graphics function, but it won't let me. How can I get the coordinate information into the graphics function?
  3. I'm getting funny errors about things not being found when I try to create a program. What's going on?
  4. After I call glueGo() none of the function calls work
  5. I can't make the graphics work
  6. What does the Ship icon actually do?
  7. In geany, what's the difference between Build, Compile, and Make All?
  8. When I load a shared project in, it contains no source files. What do I do?
  9. Geany's Execute/Run button isn't working
  10. When I Make All in my shared folder, it tries to use files from my private space. What's wrong?
  11. It says "Must agree price every day" What does that mean?
  12. Can I add new files to the ones provided in the Trading exercise, or change their names?
  13. Have I finished?

1B IDP

  1. My code compiles on the workstations but not on ARM - sqrt doesn't work
  2. I'm having trouble with const and extern
  3. When I try to 'Make' my code it's producing strange error messages

Advanced

  1. How can I see if a key's been pressed without having to wait for the user to press the Enter key? I want something like Windows' kbhit
  2. How do I initialize static class members?

© Cambridge University Engineering Dept
Information provided by Tim Love (tl136) (to whom suggested additions should be mailed)
Last updated: February 2011