c++ tag

886 questions


1 answers
41 views
0
Is there no null character when storing a string in the c++ string class?

#include <iostream>#include <string>#include <cctype>using namespace std;void ChangeStr(string &s);int main(){ string str; while(1) { cout<<Enter a string (q to end):; cin&...

2 years ago

1 answers
23 views
0
Where should I write the default parameter in the function declaration/definition?

Where should I write the default parameter?In the function declaration?In the function definition?Or both?The code that people wrote downI think they all wrote whatever they wantedIs there any rule?

2 years ago

1 answers
23 views
0
C++ char output

You want to express the little endian by approaching the value in the variable with char* and reading each byte by byte.For example, int dwValue = 33; char* pBuf = &dwValue; for(int i = 0; i <...

c++
2 years ago

1 answers
75 views
0
If you used a combination of C++ overloaded operators, I have a question about g++ compilation error.

During class, there was a task to implement a program that implemented complex numbers as classes and used operator overloading to spin simple tests.Among them, there was a test case where the global ...

2 years ago

1 answers
77 views
0
I have a question about the c++ template function extinction. Monsters, please crying

#pragma oncetemplate <typename Elem>class NodeList{public: class Node { public: Elem elem; Node* prev; Node* next; }; //template <typename Elem> friend class NodeSequence;public : Elem&...

2 years ago

1 answers
96 views
0
I'd like to print out all the long strings on the GDB

Is there any way to see the entire string in GDB?It keeps getting shorterI need a whole long sentence

2 years ago

1 answers
70 views
0
How do I erase elements of vector<> with an index?

How do I erase the nth element in std::vector?How do I write functions such as erase() in the source code below?std::vector<int> vec;vec.push_back(6);vec.push_back(-17);vec.push_back(12);vec.era...

2 years ago

1 answers
134 views
0
Can I delete the NULL pointer?

NULLThe pointer doesn't point at anything, so there's nothing to do with deleteIs it safe to delete?Should I check whether it is NULL or not and delete?


1 answers
22 views
0
C++ Hash Function

Implementing Dynamic Hash on C++.value = hash_function(key) ; That's what I know.key is the attributes (for example, Student ID) to classify Dynamic Hash, and I understand that value is the block numb...

c++
2 years ago

1 answers
82 views
0
How do I type the template?

template<size_t N, size_t M>class Matrix { // ....};When you have this code If you set default parameter in the function, you don't have to write it separately when you call ittypedef Matrix<...

2 years ago
« - 56 - »

© 2024 OneMinuteCode. All rights reserved.