C++ Definition and 813 Threads

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. ChrisVer

    C++ Harmonic Oscillator (with Force)

    I was wondering whether it's possible to write a code in C++ that would be able to solve the Harmonic Oscillator: \ddot{x} + \gamma x = F_{external}(t,x) With different F function inputs... I thought about creating a function with if clauses, so for different inputs by the user, the force F...
  2. ChrisVer

    C/C++ Generating Random Numbers in C++ for Scientific Applications

    Hi. I am trying to create a program that I will give the maximum range (1,...,max) from which to generate random numbers, and make it generate N=maxgen random numbers (which later I can use for example in another program). Below you can see the code I wrote: #include <iostream> #include <ctime>...
  3. D

    C/C++ Where Can I Find Good Resources for Learning C++ and Game Programming?

    Hey, guys, I would like to learn about programming in C++. Could you point out good pdf textbook or material about this? What about game programming, where should I really start? I would really appreciate the help. Thanks
  4. A

    Euler's Method and Planetary Motion

    Homework Statement Hi there, I wish to use Newton's Laws in conjunction with Euler's Method to model the motion of a planet around a star.Homework Equations 2nd Law F = m*a Law of Universal Gravitation F = -G*M1*M2/r^2 The Attempt at a Solution [/B] First I combined the two laws above...
  5. lonely_nucleus

    C/C++ C++ for Beginners: Improving Programming Skills

    I finished a course in C++ about a month ago and I would say I am almost average in programming in it. I am decent at command prompt programs but I do not have too much experience with gui programs.I have gotten to for loops and objects/methods and I did not understand ifstream.ofstream too...
  6. L

    C/C++ C++ Boolean variable - clarity sought

    This is an example from a study guide I'm using at the moment in learning C++. //Test whether a number is prime #include <iostream> using namespace std; int main () { int x, y; bool factorFound = false; cout << "Enter a positive integer: "; cin >> y; x = 2; while (x != y &&...
  7. L

    Comp Sci Solve Beginner C++ Hassles: Convert Grams to Kilograms

    Homework Statement A kilogram is 1000 grams. Write a program that will read the weight of a package of butter in grams and output the weight in kilograms, as well as the number of packages of butter needed to yield 1 kilogram of butter. Your program should allow the user to repeat this...
  8. Saitama

    C/C++ Graph Implementation using STL C++

    I am trying to implement a graph and perform BFS on it in C++. Following is the code I have written so far: #include <iostream> #include <vector> #include <list> #include <queue> using namespace std; const int V=5; vector<list<int> > a(V); int BFS(int s) { int visited[V]={0}...
  9. mr.Jelle-Beat

    C/C++ C++ on LPCExpresso-1769 to make 3D pong console

    Hello, PhisicsForumsWe are a group of students from the Avans University of Applied Sciences. We're currently doing a project where we have to design and make a 3D pong console. The idea of the project is to make a "Dedicated Video Game Console" that can be remotely controlled by remotes using...
  10. G

    C/C++ VCSEL, spin-flip model, c or c++ code?

    Is there any c or c++ written spin-flip model for simulation of dynamics in VCSELs available? Thanks.
  11. ChrisVer

    C/C++ Can C++ Write Data to a TXT File?

    Hi, is there any way to let my C++ program calculate some data and return them as results into a txt file? For example let's say I want to make a txt with the following things inside: Is it possible to write in C a program of the form: and let it somehow extract each k[j] into the text?
  12. ChrisVer

    C++ Alternatives to Euler's Method for Solving ODEs

    Hi, Apart from the Euler's method, is there any other method (with better efficiency) that can let us solve an Ordinary Differential Equation of the form \frac{dy}{dx}= f(x,y)?
  13. S

    Which points on the same curve?

    Hi everyone ın fact at the beginning ı want to select three points every curve Idid it But now I shold find which points ont the same time AND THEN I shold save its How can do it My code is here #include <iostream> #include <iostream> #include "opencv2/highgui/highgui.hpp" #include...
  14. Lobos

    What's a good intro computer science book?

    I'm going to be taking a computer science course next semester, what is a good intro computer science book or C++ programming book I can buy?
  15. perplexabot

    C/C++ C++ and pthread simple program help

    Hey all. I am currently trying to brush up on my multithreading "skills" (I dare say) that I learned in my undergrad class. I have the following code that I am trying to run: #include <pthread.h> #include <iostream> using namespace std; void* func1(void*); int main(int argc, char** argv){...
  16. 1

    Getting into data science from computational physics?

    I'm currently working on a master's degree in physics where my project uses C++. I have read about how some physics phD's were able to get data scientist roles despite working on computational astrophysics. This is a little surprising to me since I thought experimentalists would be more suited...
  17. Hepth

    C/C++ C++ : Deep Copying of an Object

    I'm making a basic neural network, and I haven't programmed in an object oriented way since java in undergraduate. Everything lately has been c and fortran 77. I have an object that is a "Network" In addition to functions and locals, it includes a pointer to an array of another object "Layer"...
  18. Saitama

    C/C++ Optimizing K^(2^N) Mod 10^9+7 in C++

    Hello again everyone! :) I have been trying to implement K^(2^N) mod 10^9+7 in C++ where both K and N are integers and $1\le K\le 10^5$ and $1\le N\le 10^9$. My idea is to use the fact that $$a_n=K^{2^N}=K^{2^{N-1}}\cdot K^{2^{N-1}}=a_{n-1}^2$$ Following is the code I wrote...
  19. P

    C/C++ How Should I Modify My C++ Code to Start Time Calculation from Zero?

    #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { cout << "Enter the total time: "; double t; cin >> t; cout << "Enter the step-size: "; double step; cin >> step; double steps = ceil(t/step); const double a = 9.806...
  20. C

    C/C++ [C++] When is it OK to forward declare templates?

    This has been bugging me for a while. I suspect the answer is in Sutter or Meyers but I don't own them. Why do so many of the top C++ people say forward declaring templates is bad style or dangerous?
  21. KleZMeR

    C/C++ How can I easily install a C++ plot library on a Mac?

    Hi All, Not sure if this is the right place for this thread but it seemed like it was. I have been trying for two whole days to get some plotting tools up and running that will work with my: OSX 10.8.5, Xcode 5.1. I have tried MathGL, Plplot, Gnuplot, Chplot, matplotpp, etc. I get errors...
  22. J

    C/C++ Help getting Boost included in my C++ program

    I've changed the Library Search Path to the folder that contains the file I'm trying to use, filesystem.hpp, and then including the file with the directive #include <filesystem.hpp>. I've also tried changing it to "filesystem.hpp"; changing the search to recursive; trying to grab it from the...
  23. I

    C/C++ C++ Code Display: Understanding Output of Exam-Related Question

    I came across this question while studying for a C++ exam. What is the screen output of the code? #include <stdio.h> int main(){ int i, counter=0; for(i=0;i<100;counter++){ i++; ++counter; } cout<<i<<' '<<counter<<'\n'; return 0; } What will this code display...
  24. I

    C/C++ How can we print odd numbers up to 99 using nested for loops in C++?

    I have my final exam for C++ tomorrow. I was studying a previous exam and I came across a certain problem that I would like to know how to do. Suppose that we want to print out the following on the screen, please complete the code segment below by filling in the blanks 1 1 3 1 3 5 ... ... 1 3 5...
  25. P

    C/C++ C++ Programming Problem: Adding Streams to a Pre-Existing Code

    I have been given a project to modify my pre-existing code to satisfy these guidelines: - Create a file called "sides.txt" and put it in the same folder as your program. - The file contains multiple lines with each line having the three sides, separated by white spaces, e.g., 3 4 5 6 8 10 5...
  26. I

    C/C++ How can a C++ function return two values to the caller without using a class?

    I was given this problem a while ago to complete as a bonus but I wasn't able to do it. I just came across it and would like to know how it should be done. Given an integer vector "vi" that is already sorted in ascending order (all elements of the vector are positive), write a function that...
  27. I

    C/C++ C++ String Functions with Pointers

    Assign the first instance of The in movieTitle to movieResult. Sample program: #include <iostream> #include <cstring> using namespace std; int main() { char movieTitle[100] = "The Lion King"; char* movieResult = 0; <STUDENT CODE> cout << "Movie title contains The? "; if...
  28. I

    C/C++ C++ *Pointer vs. Pointer* and Member Access Operator

    A pointer in C++ is represented by *. Sometimes the * comes after the variable/class/whatever such as 'Pointer*'. Other times it comes before, '*Pointer'. What is the difference between the two?What is the member access operator for? (->) According to my notes, a->b is equivalent to (*a).b
  29. I

    C/C++ C++ Pointers and the Flush function

    I need some help understanding some things. One, I understand WHAT pointers do but how are they useful and how/when are they necessary? Two, what is the purpose of the flush function? This is the definition that I've been given: "The << flush forces cout to flush any characters in its buffer to...
  30. D

    C/C++ Problem with the Haversine Formula in C++ Help

    Hello, I have the haversine function within my C++ program to calculate the distance between to points, the two tester points I have chosen are Swansea and Cardiff both located in Wales. Swansea lat = 51.622559, long = -3.934534 Cardiff lat = 51.475661, long = -3.174688 The problem I am having...
  31. J

    Comp Sci How to Implement a Timer in C++ for Repeating Code Blocks

    Basically within my whole code is 4 major chunks of code that each loop repeatedly. The obvious problem is when I run it, it will get stuck on the first chunk and loop forever, therefore never moving on the next chunk. What I need is to have each section run for 10 seconds and then move on. Is...
  32. I

    C/C++ C++ Vector Resize: Counting Down to the Test

    going through problems to study for a test Resize vector countDown to have newSize elements. Populate the vector with integers newSize down to 1. Ex: If newSize = 3, then countDown = {3, 2, 1}, and the sample program outputs: 3 2 1 Go! Sample program: #include <iostream> #include <vector>...
  33. I

    C/C++ Adding Vectors in C++: Example Code for Summing Elements with an Offset Amount

    im going through previous assignments to study for a test and i can't seem to remember how i did this one. Add each element in origList with the corresponding value in offsetAmount. Print each sum followed by a space. Ex: If origList = {40, 50, 60, 70} and offsetAmount = {5, 7, 3, 0}, print...
  34. C

    Comp Sci Need Help Running a program in C++ for Ubuntu (Linux)

    Homework Statement m working on a Engineering Project and I'm having serious trouble trying to run this program in C++. I'm following an example of the program from Program done in C but I'm trying to convert it into C++. I'm going to link the example I'm following and what I'm doing trying to...
  35. I

    C/C++ C++ Classes: Print and Update Person's Kids

    Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. End each line with newline. Sample output for below program: Kids: 3 New baby, kids now: 4 Sample program: #include <iostream> using namespace std; class PersonInfo { public: void...
  36. certainly

    C/C++ CodeBlocks output window help in C++

    Hi everyone! Fresh and new around here. I just started learning C++ and wrote a program yesterday to list all primes up-to an input n. It works just fine except for one problem. I tried listing all the primes up-to 100,000. Program completed in about 20 seconds, I scrolled up to the top but the...
  37. adjacent

    What are signed and unsigned chars?

    I am reading a book called C++ primer, which mentions about a data type of C++ called char(Character). I know that this data type can hold characters such as "A" or "5". But what does signed and unsigned char mean? The book says: "an 8-bit unsigned char can hold values from 0 through 255...
  38. J

    C/C++ Compiler error do to too much "constness" in my C++ program?

    Can someone try compiler this and tell me what error you get and what it means? https://github.com/jamkin/CSS-Template-Generator/tree/master/CSS%20Template%20Generator I get Mod note: Removed the [ I ] tags and the [ color ] BBCode tags, and replaced with [ code ] tags. There were too many...
  39. C

    Comp Sci C++ put numbers in ascending descending order

    In this assignment, you are going to write a function called sortMe that sorts the elements of an array in numerical order from highest to lowest values (descending order) or vice versa (ascending order). The interesting point of the function is that sortMe does NOT re-arrange elements in the...
  40. I

    C/C++ Reversing Vector in C++: Which Loop is Correct?

    which loop is correct for reversing a vector? please help. A. for (i = 0 ; i < NUM_ELEMENTS ; ++i ) { tmpValue = revVctr .at (i ) ; revVctr .at (i ) = revVctr .at (NUM_ELEMENTS - 1 - i ) ; revVctr .at (NUM_ELEMENTS - 1 - i ) = tmpValue ; } B. for (i = 0 ; i < (NUM_ELEMENTS...
  41. I

    C/C++ Computing x^n in C++ without Math Library

    Program should compute the power x^2 #include<iostream> int main() { double x; int n; double pow=1; cout<<"Please enter x:"; cin>>x; cout<<"Please enter n:"; cin>>n; LOOP FOR X^N pow=pow*x cout<<"The result is: "<<pow<<endl; return 0; } as you can see, there is no math library included and i...
  42. I

    C/C++ Compute the area of a triangle c++

    compute the area of a triangle. write an if/else statement to check if the three sides provide a valid triangle. to make a valid triangle, all sides have to be positive and the sum of any two sides must be greater than the third. add a while loop so that if the sides are invalid the user is...
  43. J

    C/C++ C++ function to split a string by whitespace, ignoring any whitespace in quotes

    Could someone comment on, or perhaps help me fix/simplify/optimize/elegantify, a function I'm trying to make to split a string by whitespace into a vector of strings, discounting any whitespace in quotes? Intended behavior: name="someName" class="class1 class2 class3" id="someId"...
  44. S

    C/C++ What Is the Equivalent of Subroutine in C++?

    Hello, I am relevant new user to C++ while i am quit comfortable using fortran! One of my favourite thing to use in fortran was the subroutines but i struggling to find something similar in C++. Let me give you an example: In Fortan: subroutine test(Tabular1,Tabular2) ... ...
  45. T

    Results from TLE & SGP4 propagation - don't seem right & with interpretation

    Greetings all ! I have this problem with SGP4 propagation, that I hope someone can help me out with. I acquired a TLE of the ISS from internet and used the C++ SGP4 propagator to compute future position and velocity vectors of the Station. I am unsure about some aspects of results though and...
  46. T

    C/C++ How to write C++ code using SGP4 to propagate satellite position

    Greetings all ! I really hope this is the right sub-forum for my question, I have chosen it because I've seen TLE being mentioned a couple of times around here. I have done some reading on astrodynamics and orbital mechanics, but I am relatively new to coding. I would like to write some C++...
  47. I

    C/C++ How to Populate a Vector Using a For Loop in C++?

    ok I am working on some activities and i can't get past this one. Write a for loop to populate vector userGuesses with NUM_GUESSES integers. Read integers using cin. Ex: If NUM_GUESSES is 3 and user enters 9 5 2, then userGuesses is {9, 5, 2}. Sample program: #include <iostream> #include...
  48. I

    C/C++ "Understanding the C++ For Loop Variable [i]"

    ok so i realized my problem with c++ is that i don't really understand for loops. well it's not exactly the loop itself but i don't understand the loop variable [i]. what is for EXACTLY? why is it needed? why can't you just use the other variable you are using? why does this extra variable need...
  49. I

    C/C++ Write C++ Nested Loop Program to Print 0-userNum

    Print numbers 0, 1, 2, ..., userNum as shown, with each number indented by that number of spaces. For each printed line, print the leading spaces, then the number, and then a newline. Hint: Use i and j as loop variables (initialize i and j explicitly). Note: Avoid any other spaces like spaces...
  50. K

    Comp Sci Matrix inverse with LU decomposition in C++

    Homework Statement the problem is to find the inverse of a 3x3 matrix using LU Decomposition with C++ command, with the numbers designated. in my case, my numbers for the matrix are '306 410 780' #include <stdio.h> #include <iostream> #include <stdlib.h> #include <math.h> using namespace std...
Back
Top