C++ is a general-purpose programming language. It was originally designed as an extension to C and has a similar syntax, but it is now a completely different language. Use this tag for questions about code (to be) compiled with a C++ compiler. Use a version-specific tag for questions related to a specific standard revision [C++11], [C++14], [C++17] or [C++20], etc.
In C++, a file is generated as .cpp, on compilation it becomes .obj and finally after linking, it becomes .exe. What is the final stage of a Java file? It is initially .java, on compilation it becomes ...
I want a field of quads with textures on them to be displayed. Howerver I'm not getting any image or vertecies displayed. All quads should be placed next to eachother with no space in between. And i ...
i would like to loop over a fixed number of objects (all of the same type) without having to first explicitly create an iterate-able container with those objects as members, for example:
object_type a,...
asked 16 mins ago
newbie
58233 silver badges1212 bronze badges
This is a C++ code vector initialization. vectorv(n,1). Here what does mean by 1? I know that n is the size of the vector. But what is the job of 1 here?
How can I get raw bytes of in memory database using SQLite3?
Database creates using:
int result = sqlite3_open(":memory:", &db);
I want to send database raw data to server not saving to ...
I have the following code sample:
template<typename T>
void print(T t) {
std::cout << t << std::endl;
}
template<typename Key, typename Value, typename F>
void traverse(...
Whenever I try to implement my structure in my product.cpp file, I can't perform an instance of the object, because I get the following error "invalid use of incomplete type".
The temporary ...
I am trying to assign and print vector<vector<int>> dynamically , However i cannot figure out how to do this i am stuck here is my program
#include<iostream>
#include<vector>
#...
asked 46 mins ago
Phil
1611111 bronze badges
Hey I have this question for school but I have no idea how exactly to even go about doing it.
In a 2D environment we have a robot's location with its radius and its movement direction.
there is also a ...
this code is working fine and prints "yes":
#include <iostream>
using std::cout;
using std::endl;
class A {
public:
virtual void talk() { cout << "person talking"...
I've been sitting here for a few hours now, trying to figure out how an array can be initialized with specified array[index], no not 0-n, but n-N, meaning that index can be: 3, and then it increments ...
asked 50 mins ago
John Smith
72233 gold badges1010 silver badges2828 bronze badges
I've started learning C++ and trying to figure out how header files work.
I have
main.cpp
#include <iostream>
#include "fibonacci.h"
using std::cout;
using std::cin;
using std::endl;
...
We have an azure pipeline with a Microsoft-hosted agent that builds our c++ project for Linux, Mac and Windows. Because we use the std::filesystem library we needed to specify a higher GNU version in ...
Let's say i have a byte sized variable like : unsigned char a = 0b0000'1111
and i turn on / off a certain bit using bit masking. I wanna know is this process of turning on / off slow for array of such ...
I'm using std::count_if() to iterate over each "column" of a vector of vectors, and return the # of items both greater than some value, and within a certain 'range of rows'. For some reason, ...
I have developed a distributed solver for a particular application using MPI. I need to perform a time study by running the solver for different problem sizes and different number of processors to see ...
I want to create an edit function, the flow is
In a loop, read the next record until there are no more records.
If we found the record we want:
Write the new data to the output file
else
Write the old ...
I am creating a Thread which contains a While loop. It gets data from the API site every iteration, checking the new data.
string data;
while (true) {
data = get_contents ('http://example.com/');...
I want to try to make a little (U)EFI bootloader in c++, but, when I try to compile my code (with g++) gives this error:
boot.cpp: In function ‘EFI_STATUS efi_main(EFI_HANDLE, EFI_SYSTEM_TABLE*)’:
...
why does it output 202?? stoopid , if you change the x and the intin any of the two brackets, the result changes... whyy?
code:
#include <iostream>
using namespace std;
class X {
public:
int ...
I am having a hard time figuring out a bug in my TCP client-server app. The problem I am facing: in my recv function do-while loop, if the condition is bytes > 0, the function hangs forever. ...
If I use the fputws without setlocale, only ASCII letters get printed. It seems that setlocale is necessary, and according to this site, both setlocale(LC_CTYPE, "UTF-8") and setlocale(...
I'm using windows 10 ming g++ compiler. When I was using macOS for compile and run at the same time I use the command.
g++ name.cpp && ./a.out
It worked but when I tried to use this in ...
I have made the following example to test my understanding of references:
#include <iostream>
int test(){
int a = 1;
int &b = a;
return b;
}
int main(int argc, const char * ...
i already saw the solution of the problem and its not that big different than mine i need explaination of why i got Abort called and how to solve it 100% ?
void update(long int *arr, int l, int r, int ...
I was doing some experiments with unions when I encountered a problem.
union U
{
// struct flag for reverse-initialization of each byte
struct rinit_t { };
constexpr static const rinit_t rinit{};...
As i have studied that Derived class can access protected member of base class. In derived class, protected member of base class works as public in derived class. But when i implement this , i get a ...
There is any cost of taking 2d array as input ?
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
Is it O(n^2) time complexity or O(1)?
I already know that i could abuse ImageFileExecution Options as well as AppInnit_DLLs, but i need admin rights for both... since i dont want to use uac-bypass (because malware-scanner would count it ...
I'm trying to generate accurate code coverage for my templated math classes. I'm default instantiating every method inside a template class with a trick from here
template class Vector2D<float>;
...
asked 3 hours ago
mtosch
24233 silver badges1313 bronze badges
This is the code that I've written to remove spaces in the given string. It normally works.
string a = "hello there world";
int n = a.size();
for(int i =0 ;i<n;++i){
if(a[...
Basically, trying to print C++ unicode file names to Visual Studio's debug panel (because unicode strings are not correctly displayed in console window anyway) using the code below.
If I try to print ...
Suppose I have to use this template which I cannot modify:
// cannot modify
template <typename C,typename T>
void foo(C& c,const T& t) {
// ...
std::iota(std::begin(c),std::end(...
I tried writing a function to convert a string of numbers to an integer. I get a wrong output when I run my code on VS code with g++ 9.2.0 but when I run it on repl.it, I get a right output. This is ...
asked 4 hours ago
Duc Nguyen
2111 gold badge11 silver badge33 bronze badges
I have following class
template<class T> class CT
{
T& operator()(int i,int j) const noexcept
{ return indx[i*N+j]; }
private:
T *indx;
int N;
};
Now some where in my ...
asked 4 hours ago
A2LBK
1,02311 silver badge1111 bronze badges
I think I saw this a long time ago; a way to get a string containing the name of a unicode character by using Win32 API calls. I'm using C++ Builder so if there is support for it in the VCL library ...
asked 4 hours ago
Max Kielland
5,08177 gold badges4545 silver badges8484 bronze badges
void writeToEditor( QString partOfText, double readBytes )
{
QString combineHtml = "";
for( int j = 0; j < readBytes; j++)
{
if(partOfText[j] == '...
asked 4 hours ago
Aquarius_Girl
16.8k5353 gold badges173173 silver badges329329 bronze badges
I am trying to write hello world in C++ using different tactics(for fun).
Can you show me other fun ways I can print "Hello World" in C++ language.
right now I have these methods:
#include &...
I searched everywhere and results tells everywhere is like `same key can't be inserted in map
I am asking why ? why we can not insert it in map. i want to know the reason not the rule like it can't be ...
I am trying to use single-dimensional array in c++ winRT component
Class.idl
namespace MyClass
{
[default_interface]
runtimeclass Class
{
Class();
String[] aaa(String[] v);
...
asked 4 hours ago
arachide
7,4021717 gold badges6464 silver badges124124 bronze badges
I try to follow the next exemple in order to create a simple synthesizer app:
https://codelabs.developers.google.com/codelabs/making-waves-1-synth/#0
but, when I pressed Run, the Build failed.
void ...
I just don't get it, really...
I have my class:
Class Test{
int testInt;
int* func() const { return &testInt;}
};
Why is this an error?
I have a template base class with a friend function that can make an operation (connect) with another class. If I derive a class from such template base I need to make use of std::static_pointer_cast&...
I'm new to c++.
I'm trying to printout data points shown on my terminal into a txt file.
Here's an image of data I want to printout.terminal showing data points
I'm new in C++ and CMake projects. I write (with CLion) very simple application that uses mysql connector.
This require to install on system libmysqlcppconn-dev. That is no problem on system where I ...
asked 6 hours ago
nicram
21311 gold badge55 silver badges1818 bronze badges
I’m developing an iOS app and solved the interoperability Swift-C++ in the CPU side wrapping the C++ classes in Objective-C. But on the GPU side, I don’t Know if exists any way of call and retrieve ...
I am writing a code for Prime factorization of a number but I am not able to run my program, encountering the Process terminated with status -1073741510 I am new to computer science. Please find my ...
I was reading notes issued to us by a college instructor and came cross the statement in bold,
What does the statement actually mean ? How can c++ be written in the style of another programming ...
If I have a file like this, everything works as expected:
#include <filesystem>
#include <iostream>
int main() {
std::filesystem::path o = "C:\\Windows\\write.exe";
auto s =...
asked 6 hours ago
Steven Penny
75.6k4545 gold badges291291 silver badges335335 bronze badges
I want to extend my programs to different platforms, but I can't find any information on the internet about it. What kind of macro should I use for that?
I'm using CLion on Linux.