What is C++: Definition and 812 Discussions

C++ () is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms.C++ was designed with an orientation toward system programming and embedded, resource-constrained software and large systems, with performance, efficiency, and flexibility of use as its design highlights. C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including desktop applications, video games, servers (e.g. e-commerce, web search, or databases), and performance-critical applications (e.g. telephone switches or space probes).C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20). The C++ programming language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then amended by the C++03, C++11, C++14, and C++17 standards. The current C++20 standard supersedes these with new features and an enlarged standard library. Before the initial standardization in 1998, C++ was developed by Danish computer scientist Bjarne Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided high-level features for program organization. Since 2012, C++ has been on a three-year release schedule with C++23 as the next planned standard.

View More On Wikipedia.org
  1. Sam Groves

    C++ header files and classes

    I have a class Stack with a header file Stack.h which uses up another class with a header file Activity.h I have a third class ActivityManager which uses up both the Stack and the Activity class.If I run the program and add in both Activity.h and Stack.h to the #include list I get a compilation...
  2. bartb7

    What programming languages does Bartb7 specialize in?

    There's stuff on here relevant to my day-to-day, which means I may also be able to contribute. I'm primarily focused on programming in C, C++, Python and Perl. Nothing now, just introducing myself - hello all!
  3. shivajikobardan

    How to take input in hh:mm format in C++ and parse it?

    TL;DR Summary: hh:mm format input I'm solving this problem. I've the algorithm ready. Here's it. But it's the easy part. The hard part is to code it specially in C++. (Not that I can do this in javascript). How do I take say 14:30 as input(exactly that) and parse 14, parse 30 from it?
  4. shivajikobardan

    Courses Which C++ book is best for learning algorithms and data structures?

    As I said earlier, I've already grasped basics of C++. Since my ultimate goal is to work in coding industry, for interviews, I need to prepare for algorithms and data structures, grind leetcode. Between C++ and Java, I choosed C++ because that was taught in our university. I won't read the...
  5. shivajikobardan

    I finished a 50 hr C++ course, what next?

    I am still not confident with C++ I don't think I should yet go to Data Structures and Algorithms yet because I am not very comfortable with C++. I want a book that covers problems that require Object Oriented Programming to solve problems. It should have lots of such exercises. Is there such a...
  6. shivajikobardan

    Comp Sci I'm not understanding Parameterized Constructors in C++

    I am not understanding this code meaning #include<iostream> #include<cstring> using namespace std; class String { private: char *s; int size; public: String(const char *str) { size=strlen(str); s=new char[size+1]; strcpy(s,str); } ~String()...
  7. shivajikobardan

    Comp Sci Call by reference C++ confusion

    Full code goes here: The goal of the program is to overload the extraction operator for cout. #include<iostream> using namespace std;class Time { private: int hour; int min; public: Time() { hour=min=0; } Time(int h,int m) { hour=h; min=m...
  8. shivajikobardan

    Comp Sci How do "min" and "hour" get their values in this C++ code?

    How does "min" and "hour" get their values in this C++ code? Full code here: #include<iostream> using namespace std;class Time { public: int hour; int min; Time() { hour=min=0; } Time(int h,int m) { hour=h; min=m; } Time add (Time t)...
  9. D

    Learning to Code Game Enemy AI in C++ from Scratch or in Assembly?

    Hello, To keep my questions straightforward they are below. How do I learn how to code Game Enemy AI in C++ from scratch and what are the top resources you recommend(Books, Tutorials, CD-Roms, Videos)? How do I learn how to code Game Enemy AI in Assembly Langauge from scratch and what are the...
  10. M

    C/C++ How to import .CSV table in C++

    Hi PF! Given a .csv file with the first row a name (string) and successive rows doubles, how can I read and manipulate this data in C++? Typically I just google these sorts of questions, but I'm seeing so many links. Do you have one that you recommend, or do you have a function you've written...
  11. M

    MATLAB Can I run sections of code independently in Python and C++ like in MATLAB?

    Hi PF! I typically code in MATLAB. Here, if I run the following program %% Section 1 x = 5; y = 2; %% Section 2 z = x + y; everything works. But now let's say I wanted to change line 5 to z = x - y. In MATLAB this is simple: I can simply change line 5 and rerun section 2. Is there a way to...
  12. Vick

    C/C++ How to install/build any C++ library/package on VScode for Windows10?

    I'm new to c++ and I have written a code. I need to plot using matplotlibcpp at matplotlib-cpp However I do not know how to install it. I've tried vcpkg, but it doesn't work. I want to be able to use it in my code when I do: For example in Python, I would simply do the following to install a...
  13. D

    Solve Euler Method in C++ for Beginners

    Summary: Problem with Euler Method in C++ Hello, I have a very difficult problem for me (a beginner in programming) how to make the version of the euler method presented in c ++ with the void, float functions, so that the program will calculate from the data that I enter during the program...
  14. user366312

    Polymer simulation source code in C++ and Python

    I am absolutely new to Polymer simulation. I am trying to understand the simulation by analyzing source code written by others. Can anyone tell me what are the differences between the following three source code in terms of their objectives? Monte-Carlo-simulation-of-polymers...
  15. martusa

    Comp Sci Drawing Figures in C++: Put Circle Pattern in Square

    i only managed to draw a square and don’t know how to put circle pattern inside of it #include <stdio.h> int main() { int totalrowcol; printf("Enter the number of rows: "); scanf_s("%d", &totalrowcol); for (int rowno = 1; rowno <= totalrowcol; rowno++) { for (int...
  16. S

    C/C++ How can phase singularities be implemented in C++?

    hello i would like to ask how to implement phase singularities in C++. thanks very much.
  17. M

    C/C++ C++ polynomial operations

    Hey! :giggle: I am looking at the following: a) Create a class QuadraticPolyonym that describes a polynomial of second degree, i.e. of the form $P(x)=ax^2+bx+c, a\neq 0$.The coefficients have to be givenas arguments at the construction ofan instance of the class. Implement a method...
  18. M

    C/C++ Matrix33 in C++: Create, Add, Check & Program

    Hey! :giggle: I am looking the following exercise about C++. (a) Create a class Matrix33 that describes a 2-dimensional $3\times3$ array of integers. At the construction of an element of the class allpositions of the array are initially zero (zero matrix). Implement methods to read and...
  19. B

    Why are structs used for linked lists and classes used for binary trees?

    Why are struct use for linked list and classes used for binary tree. honestly what is the different between a class and a struct? I have a teacher one tell me that a class was a struct on steroids. but what does that really mean ?
  20. Linda8888

    Comp Sci What is the Best Way to Use Namespaces in C++?

    using namespace std; using vit = vector<string>::iterator; void print(const vector<string>& s) { for(vit it = s.begin(); it != s.end(); ++it ) { cout << *it << endl; } }
  21. Z

    Wrong solution order using Runge Kutta 4

    Hi, I'm trying to simulate a 3-body problem with a star at the center of reference system and 2 body orbiting around it using Runge Kutta 4. The 2 bodies perturb each other orbits gravitationally, so my ode system is actually a coupled armonic oscillator and I evaluate the solution of both...
  22. Y

    C/C++ Question about New syntax of C++

    Hi I have been literally studying back class overloading in the new C++ syntax( at least that's what I call). This is on class template that is very much like class. I want to verify whether my translation is correct or not. In the program, I have the constructor and operator[] with throw catch...
  23. Y

    C/C++ Operating system and C++

    Hi I want to know a little more about learning operating system. My grandson told me he is taking a class in operating system and the teacher use C and C++ mostly. He and his friends are in trouble because his school is Java based, none of them really know C++ and C. Is Operating system...
  24. Y

    C/C++ Question on this program with exception C++

    I am stepping through the program and I actually wrote down the steps in comment each step the debugger step through. I have a few question I still don't understand. Here is the program: //Matching catch handler with exception #include<iostream> #include<string> #include<string_view>...
  25. C

    C/C++ Running a C++ project in Xcode Mac Os

    I am trying to run an Xcode project in c++ on a Mac Os. I started by creating new project, selecting command line tool options so that I may use c++ option and proceeded with completing the product name fields and the directory where to save the project on my Mac. The default project that is...
  26. Y

    C/C++ Question in throwing a class object as exception in C++

    This is a program from Gaddis that has two exception classes inside the Rect class. It is not clear for me how it works. Ivor book declares the exception classes as individual class, not inside another class. So I cannot compare and see what I missed in Gaddis book. Here is the program right out...
  27. Y

    C/C++ Why does my program using cstring work while the one from the book doesn't?

    I followed the program from the book and it doesn't work. I simplified to show what's going on. I solve the problem and show in the second program. It's the good old cstring and the string literal again. This is from the book, it doesn't work: #include <iostream> using namespace std; int...
  28. Y

    C/C++ Please help with the divide function in C++

    Hi I just moved into Chapter 16 of Gaddis on Exception, Templates and STL. Seems like it jump a chapter. This is a partial sample from the book: I have to complete the program as shown below but compiler doesn't like it. #include <iostream> #include <functional> using namespace std; int...
  29. A

    Comp Sci Template for STL in .h File: Error Fix

    in .h file I write like this: namespace board{ template <class T> class BAdapter : public AbstractB{ public: BAdapter(); BAdapter(int x){ x=6; setSize(x); } virtual void setSize(int receivedSize){...
  30. Y

    C/C++ C++: What is ":x(a)" in Line 5? Help Needed.

    I am copying some program from youtube videos. This is the program I copied: #include <iostream> using namespace std; class Base { int x; public: Base() {} Base(int a) :x(a) { } int get(){return x;} void set(int a){x=a;} }; int main() { Base b1; Base b2(10)...
  31. jtbell

    C/C++ Puzzle with C++ constructor and overloaded operator

    I mentioned in another thread that I've been playing with a C++ class for 3D vectors, to review overloaded operators, constructors, etc. All those functions display output so I can follow which ones get called, and when. The class generates a serial number for each vector so I can tell them...
  32. harborsparrow

    C/C++ Bjarne Stroustrup's C++ book -- free to first person requesting it

    I rescued this book from being tossed out. Would someone like it? Will ship to first requester if in USA.
  33. S

    Converting State Vectors to Keplerian Orbital Elements for Binary Objects

    Homework Statement:: I'm working on a personal project to convert objects from a simulation using state vectors for position and velocity to Keplerian orbital elements (semimajor axis, eccentricity, argument of periapsis, etc.). However, the equations I am using do not calculate the...
  34. Y

    C/C++ What could be causing my program to hang on cin.getline() in C++ code?

    I have no idea why the program got hung on cin.getline() in my program. cin >> works just find. Here is the program. It is the really scaled down version of my long program. I just deleted all the irrelevant things. The structure is defined in the header file. I use debug to step through the...
  35. A

    Comp Sci Learning C++: Fixing Class & Vector Error

    I am now learning C ++ and trying to learn class and vector. I'm trying to write code, but I got an error. this is my class and enum class: enum class state: char{ empty='.', filled_with_x='x', filled_with_o='o'}; class class1{ private: class class2{ class2()...
  36. A

    Comp Sci Cin.ignore remove first character

    if(count%2==0){ //for user 1 cout<<"User 1"<<endl; cout << "Please enter your move: "; cin.ignore(); getline(cin,str); //do something } else if (count%2!=0){ //for user 2 cout<<"User 2"<<endl; cout << "Please enter your move: "; cin.ignore(); getline(cin,str); //do something...
  37. A

    Comp Sci Generate random numbers in C++

    I want to generate random numbers in C++. I do not want to use C library function (`<cstdlib> <ctime> (time.h)` ) and class. So I cannot use `rand()` function in C. I want to generate random integer numbers and I guess I can use `<random>` library in C++11. How can I use this generate random...
  38. Y

    C/C++ Efficient C++ String Manipulation: Tips and Tricks from Experts

    Question Is there anyway to copy the content of a string into a C-String and make the length of C-String the right length of the string? This is the program I try to do, of cause this is NOT working. I don't know of any way to do this. I just want to run by you experts whether it's possible...
  39. Mark44

    C/C++ C++ swap routines: pointers vs. references

    @sysprog posted this code for a nifty swap function that uses XOR in another thread in this section. This put me in mind of a couple of swap routines that I did awhile back: one with references and one with pointers. Unlike the example above, both routines do use a third memory location. Rather...
  40. sbrothy

    C/C++ Deriving from C++ STL classes?

    I'm not a newbee to C++ but I've been out of the loop for a while. I know it's discouraged, if not directly a no-go, to derive from STL classes. Something that has to do, if I remember correctly, with the STL classes having no virtual destructors. It will work in the short run but may...
  41. Y

    C/C++ Are Enums and Unions Useful in Real Life Programming?

    I have a quick question. The last 15 pages of chapter 11 is on Unions and Enumerators. Are they useful in real life programming? I can see some usefulness of Enumerators with well defined limited set of elements. The only reason for Union is to save a little memory. But what do I know.
  42. jtbell

    Other Old but good C++ textbook available for free

    Today I found out that the textbook that I taught C++ out of for several years in the late 1990s and early 2000s is now available online for free. After it went out of print, the author (Owen Astrachan at Duke University) decided to make it freely available. A Computer Science Tapestry, second...
  43. Y

    C/C++ I cannot get the size of the array after passing it to a function in C++

    I have a strange problem. I pass an Array[20] to a function. When I put cout << sizeof(Ar); (line 29 in the program) it only shows the length of one element ( 4bytes). BUT if I write cout << Ar[10]; (line 30 in the program) It will give me the correct number of the original idNum[10]. I tried a...
  44. Y

    C/C++ Please help on a C++ error message I don't understand (stack corruption)

    I have an error on this program I don't understand, it said stack corrupted around the 2 dimension array sales. //2D sales in divisions in quarters. #include <iostream> #include <iomanip> using namespace std; int main() { const int numDiv = 3;// 3 divisions const int numQtr = 4; // 4...
  45. Adec

    Comp Sci Galaxy simulation with the velocity Verlet algorithm

    To simulate the trayectories of solar systems around a black hole (i.e. a galaxy) I have 3 classes in C++: cSystem, cBlackHole and cGalaxy. cSystem assigns initial values of position, velocity, etc to a solar system. cBlackHole does the same but just for the black hole. And cGalaxy mixes...
  46. E

    C/C++ C++ Program Suddenly Ends after Reading Huge Data

    I have written a C++ code in Visual Studio 2019 that requires an input tab-delimited text file and outputs a text file that is also tab-delimited. The data within the text file are stored in a vector and then it will perform calculations, whose results will then be written in a text file as...
  47. Vick

    C/C++ What is happening to num and den in this C++ code for Stieltjes polynomials?

    I'm not at all C++ literate, but I need to understand what a C++ code is doing for a math problem regarding the Stieltjes polynomials. Especially, I want to know what is happening to the "num" and "den" in the code; the code is in this link: Stieltjes
  48. M

    Mathematica Changing output to fit C++

    Hi PF! My question is easiest to show via the following input, the output, and my desired output. input: x^2 + y^2 // CForm output: Power(x,2) + Power(y,2) desired output: pow(pos().x,2) + pow(pos().y,2) I appreciate any help you can offer. Thanks so much! Edit: for what it's worth, I'm just...
  49. L

    Comp Sci C++ random number generation

    The program works as intended. #include <iostream> #include <ctime> #include <cstdlib> int coinToss ();int main () { int tosses, result; std::cout << "How many coin tosses? "; std::cin >> tosses; size_t seeder = time(0); srand(seeder); for (int i = 0; i < tosses...
  50. B

    Second programming language to get under the belt: python vs C

    Hello everybody, I am a master student in Theoretical Chemistry and I am working in the DFT realm. Both TDDFT and DFT applied to extended systems (eg. using QUANTUM ESPRESSO). Of course I work with these softwares from a end-user point of view, not as a developer. But anyway, even if some of...
Back
Top