Questions tagged [c++]

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.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Java File : Life Cycle of Java Extension

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 ...
0
votes
0answers
7 views

Opengl - Are my buffers set up correctly for instancing?

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 ...
0
votes
2answers
22 views

c++ how to iterate over a collection of objects w/o explicitly created iterate-able container

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,...
0
votes
0answers
27 views

vector<int>v(n,1) Here, what does mean by 1? I consider n is the size of the vector [duplicate]

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?
0
votes
0answers
7 views

C++ SQLite3 getting binary data of in memory database

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 ...
3
votes
3answers
41 views

Compiler cannot deduce type of template function?

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(...
0
votes
0answers
27 views

Declare structure in header file and implement in source file

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 ...
1
vote
5answers
44 views

How to print vector <vector<int>> in c++? [duplicate]

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> #...
-3
votes
0answers
12 views

C++ how to Avoid a 2D vector withs radius?

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 ...
2
votes
1answer
28 views

Virtual member function changes result of typeid - why?

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"...
0
votes
2answers
29 views

Initialize an array with different index starting point to any N?

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 ...
0
votes
0answers
27 views

Undefined reference to 'function' that has been defined [duplicate]

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; ...
0
votes
0answers
6 views

Azure pipeline doesn't use specified compiler even though it is installed

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 ...
-3
votes
1answer
34 views

Bit masking and bit manipulation

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 ...
0
votes
1answer
29 views

Error “ no known conversion from 'std::vector<double, std::allocator<double> >' to 'double *' ” when using std::count_if()?

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, ...
0
votes
0answers
14 views

Debugging segmentation fault in parallel code

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 ...
-2
votes
0answers
39 views

Is there any method to read from file line by line? (for edit function) [closed]

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 ...
-1
votes
1answer
43 views

Clearing std :: string in while loop С++ [closed]

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/');...
-1
votes
1answer
22 views

UEFI c++: when using Print, wchar_t convertion error happens

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*)’: ...
-3
votes
0answers
31 views

academic exercise on overloading operator+ [closed]

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 ...
0
votes
0answers
22 views

C/C++ recv hangs altough local server sends data

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. ...
0
votes
1answer
29 views

What exactly is the expected format of the locale in setlocale()?

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(...
0
votes
1answer
42 views

How do I compile and run my c++ code at the same time in VS - Code (Windows)

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 ...
0
votes
2answers
52 views

Reference to variable out-of-scope

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 * ...
-3
votes
0answers
30 views

hackerrank problem introduce me “Abort Called” problem name is Array manipulation [closed]

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 ...
2
votes
2answers
22 views

Error in Accessing a Union Member in Constant Expression

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{};...
-1
votes
2answers
31 views

Can we access protected member functions of base class in derived class?

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 ...
0
votes
1answer
34 views

Time Complexity of input a data

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)?
0
votes
0answers
13 views

How can i start my Dll on startup with UserRights?

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 ...
0
votes
1answer
24 views

coverage for enable_if template class functions in C++

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>; ...
0
votes
2answers
37 views

erase() space in string [duplicate]

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[...
0
votes
0answers
22 views

Converting unicode C++ string to LPCWSTR

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 ...
1
vote
2answers
57 views

How to use std::iota with std::pair?

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(...
1
vote
1answer
48 views

Is there something wrong with my “stoi” function or my compiler?

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 ...
2
votes
1answer
41 views

decltype of pointer to class accessing its () operator

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 ...
0
votes
0answers
34 views

How to get the name of a Unicode character?

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 ...
0
votes
1answer
19 views

Text color in QPlainTextEditor - appendHtml

void writeToEditor( QString partOfText, double readBytes ) { QString combineHtml = ""; for( int j = 0; j < readBytes; j++) { if(partOfText[j] == '...
-7
votes
2answers
53 views

Can you show me different ways to write Hello world in c++? [closed]

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 &...
-3
votes
0answers
17 views

why same key can't be inserted in map [duplicate]

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 ...
0
votes
0answers
7 views

handle single-dimensional array in Microsoft Interface Definition Language

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); ...
-1
votes
0answers
6 views

build failed when using “AAudioStream” in android studio [duplicate]

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 ...
-1
votes
0answers
31 views

C++ - return adress in a const member function [duplicate]

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?
1
vote
1answer
48 views

How to avoid having to use “std::static_pointer_cast” when calling a friend function of a template base class with a derived instance

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&...
-1
votes
0answers
19 views

How to print out data points from the terminal into a txt file in c++ [closed]

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
0
votes
0answers
32 views

CMake C++ include static system library to project - how to

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 ...
-1
votes
1answer
18 views

Interoperability between Metal Shading Language (MSL) and C++ Libraries [closed]

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 ...
0
votes
3answers
46 views

Process terminated with status -1073741510 - C++ Prime Factorization

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 ...
-1
votes
0answers
45 views

What does this statement about C++ mean? [closed]

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 ...
0
votes
1answer
22 views

using-declaration may not name namespace

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 =...
0
votes
0answers
15 views

Detect what OS is used in C++ [duplicate]

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.

1
2 3 4 5
13806