go to start Ex W1
|home |print view |recent changes |changed September 22, 2017 |
exact
|You are 54.81.59.211 <- set your identity!

Sections: Setup Your Environment | Ctylechecker | Virtual Machine | Exercises | Hello World | Hello World with separate Compilation Unit | Hello World Library Project and Unit Test | Hello World Class | Compiler Errors | Common Problems |

Setup Your Environment ^

This week we are setting up your laptops and you will exercise to use Cevelop and the C++ compiler. We suggest you install Cevelop and a suitable compiler on your system natively for convenience and performance reasons. Check the setup instructions here: SetupEnvironment

Ctylechecker ^

We have implemented a plug-in for Cevelop that checks your code for various glitches, e.g. missing includes of standard headers. It focuses on various issues we usually also correct in your testat exercises. You should install this plug-in into your Cevelop.

In the IDE:

Virtual Machine ^

If you insist you can use a VM with Linux we provide.

We will be providing some memory sticks within the exercise labs to improve installation speed.

The C++ image consists of:

Exercises ^

In this week you will reproduce all example programs in chapter 0 of Lucid C++ set up the corresponding Cevelop projects and compile and run the programs. You can find the chapter in SsW1. When you have accomplished these exercises you will:

If you struggle with the first steps in Cevelop, we have a tutorial video showing how to create, build and execute projects in Cevelop. This video also covers the first three of todays exercises. But we encourage you to first try it yourself to achieve a more sustainable learning experience!

https:files/composing_hello_world_projects.mp4

Hello World ^

Create a C++ project (Hello World Executable Project) in Cevelop, compile and run Hello World. This is a sanity check for your environment. Please report to your exercise supervisor immediately, if you can not make this work.

Note:

Hello World with separate Compilation Unit ^

Hello World Library Project and Unit Test ^

Hello World Class ^

Compiler Errors ^

see also SsW1 pdf

Please try the following variations of the code given and observe if you get compile errors, or if you get interesting results from running the program. Provide your answers on SolW1!

  1. Create a separate empty C++ project that depends on your library class Hello. Add a C++ source file to that new project and use your Hello class there. To be able to compile that file using the library, you need to set in the project's properties->C++ General->Paths and Symbols on the following tabs the corresponding entries (The CUTE Library Project wizard will do that for you):
    • Includes: add to GNU C++ the project Hello as a workspace path
    • Libraries: add "Hello" as the library (-> file will be libHello.a)
    • Library Paths: add "/Hello/Debug" as a workspace path
    • Referencs: tick the Hello project as referenced project (Active configuration)
    • See:
  2. Remove the declaration of sayHello() from main(). The declaration is located in the header file, i.e. you have to remove the include of this header. What happens when you try to compile it?
  3. Remove the include guard from the header file sayhello.h and include the file twice in the corresponding main program hello.cpp. Do you expect an error? Do you get one? Why?
  4. Perform the same removal of the include guard and double inclusion with the file Hello.h containing the class Hello. Do you expect an error? Do you get one? Why?
  5. What happens when you compile hello.cpp without the implementation file containing the definition of sayHello()? Can you explain the error message?
  6. Since sayHello() is a function, you can call it from itself (sayhello.cpp). What happens if you call it after the output statement? What happens if you call it in front of the output statement? Why does this happen?
    • On Linux or Mac you should limit the stack size using ulimit -s 32 before you run your change program or better run it in a debugger

Common Problems ^


|home |print view |recent changes |changed September 22, 2017 |
exact
|You are 54.81.59.211 <- set your identity!

Ex W1
go to start