Questions tagged [c++98]

The 1998 revision of the C++ standard, ISO/IEC 14882:1998.

In 1998, the C++ standards committee published the first international standard for C++ ISO/IEC 14882:1998, which would be informally known as C++98.

The Annotated C++ Reference Manual was said to be a large influence in the development of the standard.

The Standard Template Library (see ), which began its conceptual development in 1979, was also included.

Please tag questions about C++98 with the tag, along with the tag.

Read the entire C++ history

677 questions
122
votes
6 answers

Are Exceptions in C++ really slow

I was watching Systematic Error Handling in C++—Andrei Alexandrescu he claims that Exceptions in C++ are very very slow. Is this still true for C++98?
Avinash
  • 12,851
  • 32
  • 116
  • 186
94
votes
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…
Gabriel
  • 8,990
  • 6
  • 57
  • 101
46
votes
2 answers

Vector of const objects giving compile error

I have declared the following in my code vector mylist; I get the following compile error - new_allocator.h:75: error: `const _Tp* __gnu_cxx::new_allocator<_Tp>::address(const _Tp&) const \[with _Tp = const A]' and `_Tp*…
Satabdi
  • 612
  • 1
  • 5
  • 8
32
votes
1 answer

Why does C++'s "using namespace" work the way it does?

All students are surprised by the behavior of C++ using-directives. Consider this snippet (Godbolt): namespace NA { int foo(Zoo::Lion); } namespace NB { int foo(Zoo::Lion); namespace NC { namespace N1 { int…
Quuxplusone
  • 23,928
  • 8
  • 94
  • 159
31
votes
1 answer

What is the correct way to initialize static data members in C++ (98, 11 and 14)

What is the right way to initialize static data members in C++? I'm also interested in how it has changed from C++98, to C++11 to C++14. Here is an example: // bufferedOutput.h class BufferedOutput { // Static member declaration. static long…
bodacydo
  • 75,521
  • 93
  • 229
  • 319
29
votes
1 answer

Why is std::list bigger on C++11?

With this code: #include #include int main() { std::cout << sizeof(std::list) << std::endl; }; I managed to notice that on GCC 4.7 the size of std::list on C++98 is 16 bytes, and its size on C++11 is 24 bytes. I…
André Puel
  • 8,741
  • 9
  • 52
  • 83
27
votes
4 answers

Interface for returning a bunch of values

I have a function that takes a number and returns up to that many things (say, ints). What's the cleanest interface? Some thoughts: Return a vector. The vector would be copied several times, which is inefficient. Return a vector*. My…
Martin C. Martin
  • 3,565
  • 3
  • 29
  • 36
22
votes
3 answers

Why does writing into temporary string stream object only print object addresses?

The following snippet is simplified version of a logger that I use. It extends std::ostringstream and can be filled using the <<-operator. Upon destruction all content is written to std::cout. Writing (<<) directly into a temporary object, Logger(),…
nils
  • 2,424
  • 1
  • 17
  • 31
20
votes
4 answers

Time complexity of removing items in vectors and deque

I have read that time complexity of adding items to end of a std::vector is amortized constant and inserting items at the top and bottom of a std::deque is constant.Since both these containers have a random access iterator thus accessing elements at…
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
19
votes
5 answers

Does std::vector::resize() ever reallocate when new size is smaller than current size?

Possible Duplicate: std::vector resize downward If I resize() an std::vector to some size smaller than its current size, is it possible that the vector will ever allocate new memory? This is important to me for performance reasons.
Alex Flint
  • 6,040
  • 8
  • 41
  • 80
15
votes
1 answer

Mixing different C++ standards with GCC

I have the following scenario: There are two components one is written in C++11 the other in C++98. Both are compiled from scratch using the same GCC 4.9. One uses the implicit default --std=gnu++98 the other explicitly sets --std=c++11. Even after…
Pascal
  • 423
  • 4
  • 13
15
votes
1 answer

"Constant expressions" prior to C++11

The constexpr keyword was introduced in C++11, as (I think) was the corresponding idea of "constant expressions." However, this concept was implicitly present in C++98/c++03, since array declarations require a constant expression: // valid: int…
Kyle Strand
  • 15,941
  • 8
  • 72
  • 167
14
votes
1 answer

Is value initialization part of the C++98 standard? If not, why was it added in the C++03 standard?

Cheers and hth. - Alf made a comment in this answer that value initialization is arguably a new feature of C++03 compared to C++98. I wonder what he meant. Is value initialization part of C++98? Is it present in concept but not in name? Why was it…
Praxeolitic
  • 22,455
  • 16
  • 75
  • 126
14
votes
3 answers

c++ array zero-initialization: Is this a bug, or is this correct?

Note: We are speaking about (supposedly) C++98 compliant compilers, here. This is not a C++11 question. We have a strange behavior in one of our compilers and we're not sure if this is Ok or if this is a compiler bug: // This struct has a default…
paercebal
  • 81,378
  • 38
  • 130
  • 159
14
votes
1 answer

C++11 Exception's destructor allows to throw now?

any idea why virtual ~exception() throw() is in C++98, but virtual ~exception() is in C++11? What's the design decision that allows C++11 to throw in the destructor of the class exception? From here: c++98: class exception { public: exception ()…
hong pei
  • 929
  • 2
  • 13
  • 27
1
2 3
44 45