spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » C++ » Page 3
error: too few arguments to function 'std::vector
Your definition goes like:- std::vector<std::string> buymngr(FILE *buyfp) so it's expecting FILE* type as its argument whereas you're calling it:- buymngr(); without any arguments.

Categories : C++

OpenGL Full Depth With Partial Color Write
Well, I talked to someone who encountered an error like this and I resolved the problem in the process. It turns out that everything in the white part at the end of the first pass is not white, but NaN in reality. GDEBugger displays the values as (255, 255, 255, 255) because it must not have support for displaying any other texture formats. It just says: "NaN, you must mean white :P". Well, why

Categories : C++

Unexpected behaving of cin.clear();
Discarding everything that's in the input stream is not generally a useful thing to do. Someone could feed you a file to stdin, for example, in which case you'd discard everything, or your OS might buffer differently than you expect and you'd end up with unpredictable results. What you really want to do is to ignore the rest of the current input line. The easiest way to do this is to say #include

Categories : C++

Passing arguments to command pattern
The only way to do this at runtime is to uniformly pass parameters when calling, you could use a std::unordered_map<std::string, boost::any> or similar as the single argument. Each param would have a name and you will have to cast back any to the original type.

Categories : C++

Which data structures are using how much memory
In code, you can just use the sizeof function. If you need a tool, you can just look for "Profiling tool C++" on your favorite search engine. You gonna have a lot of results.

Categories : C++

producer consumer (using Monitor) code is not working when sleep() is used?
I see the output being printed when i use fflush(stdout) while(true){ cout<<"["<<b.consume()<<"] "; fflush(stdout) } Output: Magnum@SimpleGuy:~ [52]$ ./a.out [1] [2] [3] [4] [5] [6] [7] [8]

Categories : C++

LookUp Table for 16-Bit Mat Efficient way?
The source code of LUT is in this file: https://github.com/Itseez/opencv/blob/fd59551ff0648d33568d7fc63164bf86c5d3ccb6/modules/core/src/convert.cpp OpenCV can use several methods for performing lookup-table transforms efficiently: it can use Intel IPP library (class IppLUTParallelBody_LUTCN, for 3 or 4-channel images). If have Intel IPP, you can just copy the code of this class and use ippiLUTPal

Categories : C++

Is there a way to check duplicated connection in Qt?
You can use Conan which is a connection analyzer for Qt. Using it you can see object hierarchies, object inheritance, signal/slot connections, and signal emissions at run time. It claims that : Conan has been used to identify multiple duplicate connections in the source code of Qt! An other option is to use GammaRay which is a perfect tool to analyze your Qt application in many aspects. Of

Categories : C++

How to make Comparable Class in C++
You need to do a downcast, there is no generic way to get the radius. If you are sure the only object passed to it will be of type Circle, then a static cast would suffice. If that is not the case then try to use a dynamic_cast to check if it is a Circle object. If it fails then just return false. Note: dynamic_cast would slow down the performance. bool operator > (Comparable& op2) {

Categories : C++

Unexpected output in my simple class function. Why?
Please try this: int getPay() { if (hoursWorked <= 35) return hoursWorked * hourlyPayRate; else if (hoursWorked > 35) // Hourly rate for the first 35 hours and 1.5 time for // the remaining = (hours -35) return (35 * hourlyPayRate ) + ((hoursWorked-35) * (hourlyPayRate * 1.5)); }

Categories : C++

C++ std::istream readsome doesn't read anything
auto ssize = stream.readsome(&justOneChar, 1); 1 is the maximum number of characters to read. If the streams internal buffers are empty when you call it, you'll get beck zero as a return value. The following quote (with my bold) shows this aspect: streamsize readsome (char* s, streamsize n); Extracts up to n characters from the stream and stores them in the array pointed by s, stop

Categories : C++

C++ Decorator - Not working properly
Well, the first problem that you have is a problem with your include guard. It should be: #ifndef __TOWER_H__ #define __TOWER_H__ You might have other problems as well. BTW, you shouldn't use names that begin with two underscores, since they are reserved.

Categories : C++

Why is return value optimization happening here
Because you've quoted an irrelevant paragraph. The relevant one is the one above (from the same source): If a function returns a class type by value, and the return statement's expression is the name of a non-volatile object with automatic storage duration, which isn't the function parameter, or a catch clause parameter, and which has the same cv-unqualified type as the return type of the func

Categories : C++

Implicit Type Promotion Order for Custom Class
The C++ language has no way to specify an implicit conversion precedence order and I can't see any way to meet all your requirements. The best solution here is to remove your operator int(). I know you said you don't want that alternative , but calling .get() is only six more characters of typing, once when you first write it. Then not only does it solve your ambiguity but it can prevent obscure

Categories : C++

Warning when connecting c++ signal to qml slot
I have defined qml slot like this : You are wrong. It is not slot definion, it's connection itself (the adding of QML handler for signal value_changed of object controllerObject). That's why you code works. But in this line : connect(this, SIGNAL(value_changed(double)), (QObject*)ui->view->rootObject(), SLOT(onValue_changed(double))); You are trying to connect existing signal value_cha

Categories : C++

Stuck on arrays
Change your code to read from file char by char. File length is unknown. Do this untill End Of File: inFile.seekg(0, ios_base::end); int fileLen = inFile.tellg(); inFile.seekg(0, ios_base::beg); for(int i =0; i<fileLen; i++) { char Arr[1]; inFile.read(Arr, 1); sum += Arr[0]; } inFile.close(); //sum is your answer

Categories : C++

C++: Problems creating a child class within a parent class
I don't think it is possible for a parent class to have an instance of a child class. You can use a child class pointers instead of child class objects for your purpose. Define child classes in separate header files. Add forward declarations of child classes in parent class header file. Use child class pointers instead of child class objects. Initialize child class pointer members of parent cl

Categories : C++

How to rename a printer in C++ on Windows?
You can use the SetPrinter function to rename a printer. You would set the Level parameter to 2 and the pPrinter parameter would point to a PRINTER_INFO_2 structure. The PRINTER_INFO_2::pPrinterName field lets you change the printer name. Note that the docs for SetPrinter say: To modify the current printer settings, call the GetPrinter function to retrieve the current settings into a PRINT

Categories : C++

Virtual template function visitor workaround with template derived classes
One possible solution was mentioned by Jarod42, namely to specify all possibly occuring types. Usually, however, you want to give a standard implementation taking a Base* as well, and overload this only when required. struct Type1 {}; //... struct TypeN {}; struct Visitor { virtual ~Visitor() {} virtual void visit (Base*) const = 0; virtual void visit (Derived<Type1>* d) const

Categories : C++

How to tell if Windows partition is active by a path on it?
Check this Link (http://msdn.microsoft.com/en-us/library/windows/desktop/aa365451(v=vs.85).aspx) PARTITION_INFORMATION has BootIndicator. but it is not guarantee about the running windows was booted by that partition. Edited It is a example function tested on Windows7. I think 'activate' partition is not your goal. The 'activate' has meaning such as bootable USB device. I don't like WMI but it

Categories : C++

when running program it has me enter two lines after name? help please
There's no need for cin.ignore(); Simply write it as: Speaker *getSpeaker() { Speaker *theSpeaker; theSpeaker = new Speaker; cout << "Please enter Speakers information" << endl; cout << "name: " ; getline(cin, theSpeaker->name); cout << theSpeaker->name; cout << " phone number: "; cin >> theSpeaker->phoneNumber; cout << " Email Address: "; cin &

Categories : C++

For loop not letting me change input
It looks like your if statements are not doing what you expect. For instance: if (grade[i]='B') { // This code will *always* execute } You ought to be using the double equals == to compare a value, and a single equals = to assign a value. (Edit after additional code change) Inside the for-loop, you are trying to use cin to read in a single character. However, since the z is an integ

Categories : C++

How to pass keyPressEvent in Qt to base class?
If you reimplement this handler, it is very important that you call the base class implementation if you do not act upon the key. In C++ if you want to call a base class method, you use the :: scoping operator to do so. In the case to defer to the base class's implementation, just write: return QWidget::keyPressEvent(k); That's what "call the base class implementation" means.

Categories : C++

C++ unable to assign objects passed as pointer in methods to variable
You need to declare and initialize storage for static objects: Object_Class *MyClass::object = nullptr; void MyClass::setObject_Class(Object_Class *var) { object = var; }

Categories : C++

Passing references to pointers
You can't bind a reference to a temporary. One possible fix would be this: bool insertSymbol(String& symbol, Expression*& root) { if (root == nullptr) { // base case root = new Expression(symbol); return true; } return insertSymbolHelper(symbol, root); } bool insertSymbolHelper(String& symbol, Expression* root) { if ((*(*root).getSymbol()).c_str()[0] =

Categories : C++

Computing Histogram of Oriented Gradients
The third parameter channels in the call to cv::calcHist(...) should not be 0 (which makes it a null pointer). OpenCV expects here a pointer to an array of indices depicting the channels of interest. Since you want to use the first channels (index 0), your code should look like this: int channels[] = { 0 }; calcHist(&cell_fourPx, 1, channels, ...);

Categories : C++

[Error expected identifier or '(' before '{' token]
The #defines at the start of your file cause those function names to be replaced with semicolons. In particular, this one: #define data(); is causing this: void data() { to become this: void ; { which causes your error, since the function name and parenthesis are missing and an unneeded semicolon is added.

Categories : C++

coredump at __correctly_grouped_prefixwc
First, although __correctly_grouped_prefixwc caused the segmentation fault, it's likely that it was passed incorrect arguments from some other piece of code, perhaps strtod or strtol or something that called them. That being said, here is how to set things up so that gdb can show the line of source code in __correctly_grouped_prefixwc that caused the segmentation fault. To do source-level debuggi

Categories : C++

Writing a valid copy constructor for a hash map in C++
HashMap::HashMap(const HashMap& hm) { amountOfBuckets=hm.amountOfBuckets; hashTable= new Node* [amountOfBuckets]; for (int i=0; i<amountOfBuckets; i++) { Node* n = hm.hashTable[i]; Node** p = &hashTable[i]; *p = NULL; while (n) { Node* c = new Node(*n); // node copy constructor, should set n->next to null

Categories : C++

How to show the drive size in QDirModel
From the Qt documentation: QDir Class Reference , QFileInfo Class Reference use QDir::drives() QFileInfoList QDir::drives () [static] Returns a list of the root directories on this system. On Windows this returns a list of QFileInfo objects containing "C:/", "D:/", etc. On other operating systems, it returns a list containing just one root directory (i.e. "/"). qint64 QFileInfo::size

Categories : C++

on boost::iter_split documentation
It looks like you're right. Of course, with a concrete container to receive the token iterator ranges, all the finding happens before returning with all those ranges appended to the result container. So all the finding indeed will have been done. (Stretching the imagination a bit: Perhaps the documentation is hinting at the input side of things: if you supply input iterators, information might n

Categories : C++

Problems with changing a const char pointer
If you use std::string to store the description in the appointment class then you can make things much easier for yourself and for the people who end up working on your code. The changeDescription method would then become this: #include <string> void appointment::changeDescription(std::string const& s){ this->desc = s; } And change the calling code to this: std::string desc;

Categories : C++

Calculate y derivative of image
I think you would probably need to check out what Sobel operator does here: http://en.wikipedia.org/wiki/Sobel_operator

Categories : C++

Passing a lambda function to a generic function C++
Lambda passed as parameter via std::function specification for type safety. #include <functional> long reduce_rec(const long *A, long low, long high, const std::function<long(long, long)>& op) { long result; long n = high - low; if (n == 0){ return 0; } else if(high - low == 1){ return A[low]; } else{ long mid=(low+h

Categories : C++

Reading numbers from textfile into array
You are not reading a into your numbers, Change your code to this: if (!inputFile){ //error handling cout << "File can't be read!"; } else{ int a; while (inputFile >> a){ //Should loop through entire file, adding the index to the array for(int i=0; i<a; i++){ DataFromFile [i] = a; // fill array } } } If you are looping throu

Categories : C++

stringstream with multiple delimiters
If you are free to use Boost, you can do the following: $ cat kk.txt If they had known;; you ... wished it, the entertainment.would have You can customize the behavior of tokenizer if needed but the default should be sufficient. #include <iostream> #include <fstream> #include <string> #include <boost/tokenizer.hpp> int main() { std::ifstream is("./kk.txt"); std::s

Categories : C++

Initialization of a reference versus initialization of an object
The line der x = dynamic_cast<der&>(b); constructs an object of type der and initializes it with dynamic_cast<der&>(b) The line der& y = dynamic_cast<der&>(b); just initializes a reference. x.method(); calls method() on the separately constructed object. y.method(); calls method() on the object y references, which is d.

Categories : C++

"Invalid operands to binary expression ..." when trying to compare regex_iterators
int main() { int i = 0, f(int); f(i); } int f(int) {return 0;} Is valid code. There is a block-scope function declaration of f inside main, in the same init-declarator-list as i, which is a usual int. The same happens in your case, just in a more complicated manner. Here the function declared is regend and has a parameter of type std::regex_iterator<..> - you could have also dedu

Categories : C++

If I wanted to read in comma delineated data from an input file such as 1, 2, 3 INCLUDING the commas?
If you have boost-dev installed, then include header file <boost/algorithm/string.hpp> void readInputRecord(std::ifstream &inputFile, std::vector<std::string>& fields) { std::string line; fields.clear(); while (std::getline(inputFile, line)) { boost::split(fields, line, boost::is_any_of(",")); for (std::vector<std::string>::iterator it

Categories : C++


Recently Add
Returning the actual value of maximum of absolutes of variables
Microsoft c++ optimizing compiler has stopped working
Overloading operator[] changing value
what does the printf/snprintf format character %N do? (not %n)
Eigen and C++11 type inference fails for Cholesky of matrix product
Qt KeyPress Event on QlineEdit
Any reasons to look at alternatives to inheritance / polymorphism?
Cannot cast the structure pointer to char pointer in c++
Changing a C/++ OpenCV program to CUDA from video stabilization program
c++ change of coordinates (Pixels 1920 x 1080 to 640 x 480)
WinAPI SetSystemCursor and LoadCursorFrom - how to set default cursor?
Multiple clients in c++ server
avoid specifying redundant template parameters which contain templated function pointer
How to obtain mp3 audio packets for streaming in C/C++
How do I search for an element from each node in C++ using queue?
Difference between private static members and having them in the cpp file
Is the size of built-in datatypes in c++ managed on source code level?
Deleting elements dequeued using "top" from priority_queue c++
C++ Ordering the names of a scoreboard
QColor hsl hue precision
cannot read the text file properly anymore
g++ 4.8.* std::chrono Undeclared
How can I make a 'const tm*' from a 'const tm&'?
Can clang-format align variable or macro assignments in columns?
Obtaining First and Last Charsof Each String From A Vector of Strings
boost filesystem canonical path is not valid after conversion to const char *
SIGSEGV, Segmentation fault
Is there a way to detect if a primitive argument is variable size?
why can I pass a reference as an argument to a constructor's pointer parameter?
Which compiler flag am I missing in my build on the so file?
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.