w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » C++ » Page 1
Using a class member as a default argument for a member function
[dcl.fct.default]/8: The keyword this shall not be used in a default argument of a member function. This is a special case of a general problem: You cannot refer to other parameters in a default argument of a parameter. I.e. void f(int a, int b = a) {} Is ill-formed. And so would be class A { int j; }; void f(A* this, int i = this->j) {} Which is basically what the compiler tr

Categories : C++

How to use gmock with xcode?
I was able to get GMock working in Xcode by following these steps: Download this repo somewhere on your machine: https://github.com/macmade/gmock-xcode Open the included Xcode project, build all the targets by pressing the play button, then close the project. Add the GMock Xcode project to your Xcode project as a subproject (can drag the GoogleMock.xcodeproj file to the project browser from

Categories : C++

Out of range vector subscript C++
You have an infinite loop because i is never updated in the for loop. You need to fix the typo: for (int i=0;i<88;i+=2) ^ ^

Categories : C++

One line solution for unused out parameter reference
The most obvious solution would be to use pointers: void Limits( double* min, double* max ) { if ( min != nullptr ) { *min = myMin; } if ( max != nullptr ) { *max = myMax; } } // ... double min; Limits( &min, nullptr ); Alternatively, you could just define separate functions: void Limits( double& min, double& max ); void UpperLimit( double& max

Categories : C++

boost::asio::yield_context: unexpected forced_unwind exception
This is a Boost Coroutine implementation detail. As documented here: exceptions ⚠ Important Code executed by coroutine-function must not prevent the propagation of the detail::forced_unwind exception. Absorbing that exception will cause stack unwinding to fail. Thus, any code that catches all exceptions must re-throw any pending detail::forced_unwind exception. So, you're explicitly

Categories : C++

Forcing the instantiation of static members in a template class
You could just create static instances: struct A : Y<A>{}; struct B : Y<B>{}; struct C : Y<C>{}; static A a; static B b; static C c; int main(){ std::cout << "Number of objects in the registry: " << X::getRegistry().size() << std::endl; } output: Number of objects in the registry: 3

Categories : C++

Linker error 2019 while linking Winusb application and CUDA
The linker looks at the symbols that are required by main.cpp (i.e. that are entry points needed by main.obj), and tries to find definitions for those entry points in other modules in your project. In the case of main.obj, there was one symbol (entry point) that it could not find defined elsewhere: 1>main.obj : error LNK2019: unresolved external symbol "short * __stdcall speccud(short * const

Categories : C++

C++ Reactor using base & derived classes containing functional objects of different types
When I try to compile this (g++ --std=c++11 reactor.cpp -pthread) I get a somewhat cryptic /usr/include/c++/4.9/functional:1665:61: error: no type named ‘type’ in ‘class std::result_of<void (*(int, InstructionsStore))(const int&, InstructionsStore&)>’ This appears to be the result of trying to pass stack references to the thread constructor. These are values that are goin

Categories : C++

eclipse ncurses and xterm, unknown characters printed
These characters are what initscr() outputs to do its job. A terminal knows not to show these characters and interpret them in a special way. Since the Eclipse console is not a terminal, it has not a faintest idea. If you want your program to work in both terminals and non-terminals, you need to check whether your standard output is a terminal, and avoid using ncurses-specific functions if it is

Categories : C++




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.