Questions tagged [c++03]

C++03 is an older revision of the C++ standard. The more recent revisions, C++11 and the current C++14, are still being adopted.

In 2003, the C++ Committee responded to multiple problems that were reported with , and revised it accordingly. The changed language was dubbed C++03.

Though and more recently have superseded C++03, many compilers do not yet fully support the new standard. As a result, C++03 is still the default language standard used. Additionally, while the differences between C++98 and C++03 were primarily semantic, the C++11 standard added many new language-level features resulting in a greater impact to not only the compiler authors but to C++ programmers as well.

Please tag questions about C++03 with the c++ tag, along with the c++03 tag.

806 questions
7 answers

Can C++ code be valid in both C++03 and C++11 but do different things?

Is it possible for C++ code to conform to both the C++03 standard and the C++11 standard, but do different things depending on under which standard it is being compiled?
Erik Sjölund
  • 10,690
  • 7
  • 46
  • 74
6 answers

Can virtual functions have default parameters?

If I declare a base class (or interface class) and specify a default value for one or more of its parameters, do the derived classes have to specify the same defaults and if not, which defaults will manifest in the derived classes? Addendum: I'm…
Arnold Spence
  • 21,942
  • 7
  • 74
  • 67
9 answers

Purpose of Trigraph sequences in C++?

According to C++'03 Standard 2.3/1: Before any other processing takes place, each occurrence of one of the following sequences of three characters (“trigraph sequences”) is replaced by the single character indicated in Table 1.…
Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212
8 answers

What differences, if any, between C++03 and C++11 can be detected at run-time?

It is possible to write a function, which, when compiled with a C compiler will return 0, and when compiled with a C++ compiler, will return 1 (the trivial sulution with #ifdef __cplusplus is not interesting). For example: int isCPP() { return…
Armen Tsirunyan
  • 130,161
  • 59
  • 324
  • 434
14 answers

How can I pass a class member function as a callback?

I'm using an API that requires me to pass a function pointer as a callback. I'm trying to use this API from my class but I'm getting compilation errors. Here is what I did from my…
  • 4,366
  • 9
  • 38
  • 39
3 answers

Default, value and zero initialization mess

I am very confused about value- & default- & zero-initialization. and especially when they kick in for the different standards C++03 and C++11 (and C++14). I am quoting and trying to extend a really good answer Value-/Default-/Zero- Init C++98 and…
  • 8,990
  • 6
  • 57
  • 101
10 answers

Is there any reason to use the 'auto' keyword in C++03?

Note this question was originally posted in 2009, before C++11 was ratified and before the meaning of the auto keyword was drastically changed. The answers provided pertain only to the C++03 meaning of auto -- that being a storage class specified…
Carson Myers
  • 37,678
  • 39
  • 126
  • 176
10 answers

initialize a const array in a class initializer in C++

I have the following class in C++: class a { const int b[2]; // other stuff follows // and here's the constructor a(void); } The question is, how do I initialize b in the initialization list, given that I can't initialize it inside…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
2 answers

What are the differences between C-like, constructor, and uniform initialization?

To the best of my knowledge, there are three ways to initialize a variable in C++. int x = 0; // C-like initialization int x (0); // Constructor initialization int x {0}; // Uniform initialization The uniform initialization was brought on…
  • 16,205
  • 16
  • 71
  • 126
3 answers

error: anachronistic old-style base class initializer

The following code produces the subsequent compilation error on all versions of GCC that I've tried, in C++98, C++11 and C++14 modes: struct T { T(void* x) : (x) {} }; // main.cpp: In constructor 'T::T(void*)': // main.cpp:3:18: error:…
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
11 answers

Which Typesafe Enum in C++ Are You Using?

It is common knowledge that built-in enums in C++ are not typesafe. I was wondering which classes implementing typesafe enums are used out there... I myself use the following "bicycle", but it is somewhat verbose and limited: typesafeenum.h: struct…
Alex Jenter
  • 4,324
  • 4
  • 36
  • 61
6 answers

Does "&s[0]" point to contiguous characters in a std::string?

I'm doing some maintenance work and ran across something like the following: std::string s; s.resize( strLength ); // strLength is a size_t with the length of a C string in it. memcpy( &s[0], str, strLength ); I know using &s[0] would be safe…
  • 153,307
  • 27
  • 93
  • 128
4 answers

Why doesn't PRIu64 work in this code?

As per this answer, I tried printing a uint64_t, but it gives me an error: error: expected ``)' before 'PRIu64' Following is the minimal code showing what I am trying to do: #define __STDC_FORMAT_MACROS #include #include…
Masked Man
  • 1
  • 7
  • 40
  • 80
3 answers

Union initialization in C++ and C

I have built a working C library, that uses constants, in header files defined as typedef struct Y { union { struct bit_field bits; uint8_t raw[4]; } X; } CardInfo; static const CardInfo Y_CONSTANT = { .raw = {0, 0, 0, 0 } }; I know…
Alexander Oh
  • 24,223
  • 14
  • 73
  • 76
7 answers

What is the C++03 memory model for concurrency?

What is the memory model for concurrency in C++03? (And, does C++11 change the memory model to support concurrency better?)
  • 46,370
  • 69
  • 194
  • 251
2 3
53 54