c++

How do I iterate through a std::list<MyClass *> and get to the methods in that class from the iterator?

If I have the list, typedef std::list<MyClass *> listMyClass; How do I iterate through them and get to the methods in that class? This is what I’ve tried, but that is not it: (MyClass::PrintMeOut() is a public method) for( listMyClass::iterator listMyClassIter = listMyClass.begin(); listMyClassIter != listMyClass.end(); ...

client-server program, problem sending message from client to server and viceversa using TCP

Hi, I have a small program that sends and receives data from server and client and vice-versa. Everything works fine, but I can't see received messages in both sides and it is always 0 bytes. It doesn't give any compile error but doesnt work the way I wanted to. Can you please have a look at this, where I am doing wrong ? Thanks // clie...

Boost.Build best practice to introduct a pre-built libary to the project

We currently use the `lib' like this to introduce an external pre-built library into a project: lib ace_lib_static : : <name>libboost_ace-vc80-mt-sgd.lib <variant>debug <toolset>msvc <address-model>64 <search>../lib/ACE_wrappers/lib64 ; lib ace_lib_static : : <name>libboost_ace-vc80-mt-s.lib <variant>rele...

Simple fun C++ Asterisk Hill

Assume n is odd and is taken as user input. Can you write C++ code that takes the number n (being odd) and creates a star hill. For instance, assume n is 5 the output would be: * *** ***** *** * Could this entire hill be generated using 2 for loops? I havent done C++ in over 12 years and was playing with it... I was able to do: ...

Getting started with OpenGL ES 2.0 on Windows

This is a very specific questions about the steps necessary to Build a simple OpenGL ES 2.0 program on the Windows platform. The environment is Visual Studio with unmanaged C++. I go to the Khronos.org site and, frankly, find it a bit opaque because it reads like something written by a standards body. I don't want to download a "refer...

Handling input into struct elements with array

I'm doing an assignment that involves structs. You are to make a struct with three variables and declare 3 instances of that struct. The program will then ask for the user to input 9 pieces of information. I don't like having to type cout and cin unnecessarily (9 sequential times?), so I was thinking I could use loops to handle the inpu...

Controller/mini-kernel design pattern in C++

I've looked around for a simple design object in C++ to work from, i understand most of the code involved but i'm rather new to the language so a 'base' to work from would help. Concept is basicly a 'task' class as a base for a jobs to run in a loop. BaseTask class > AudioTask class Controller loop > stores a std list of pointers to t...

Lightweight Delaunay trianguation library (for c++)

I'd like to play around with some (2D) Delaunay triangulations, and am looking for a reasonably small library to work with. I'm aware of CGAL, but I was wondering if there was something fairly simple and straightforward out there. Things I would like to do: create a triangulation of an arbitrary set of points find triangle an arbitra...

C++ std::system 'system' not a Member of std

I receive an error compiling a C++ program in which of the lines makes a call from "std::system(SomeString)". This program compiled 3 years ago, but when compiling it today, I receive an error that states ‘system’ is not a member of ‘std’. Is there something that I must import to use std::system, has it been abandoned, or has it moved to...

Why do I get different outputs when encrypting using DPAPI?

...

Visual Studio addin for mass breakpoints

When I'm starting with some big code I don't know. I find useful to me to search for a constant or function name and then add a breakpoint at all the references so I can begin to understand the code. Is there a VS adding to do that quickly ? ...

Where does Visual Studio search for txt files when conducting file management operations?

I know this is a noob question, but I've worked with Python before and when you wanted to simply access a .txt file for example, all you had to do was make sure the txt file was in the same directory. I have the following C++ code below but it's not finding the Numbers.txt file that I have saved on my desktop. All I have in the file is o...

[C++/Templates] How to use a template parameter in another template parameter declared before

Hello, a template parameter can be used in another template parameter that follows it this way : template<typename T, T N> struct s { }; But is it possible to reference "T" if it is declared after "N" ? This does not work : template<T N, typename T> struct s { }; Can we help the compiler by pre-declaring "T" or doing anything els...

Integration testing C++ code from NUnit in managed code

I have a library written in c++ that I want to end-to-end test from C# via interop. Basically this library takes in some parameters and spits out a file at the other end. I want to pass requests to a com interop and then assert that all the data was written correctly to the file. Is it possible to do this? Is there an easier way? Using ...

C++ closures and templates

We all know you can simulate closures in C++98 by defining local structs/classes inside a function. But is there some reason that locally defined structs can't be used to instantiate templates outside of the local scope? For example, it would be really useful to be able to do things like this: void work(std::vector<Foo>& foo_array) { ...

Does an arbitrary instruction pointer reside in a specific function?

I have a very difficult problem I'm trying to solve: Let's say I have an arbitrary instruction pointer. I need to find out if that instruction pointer resides in a specific function (let's call it "Foo"). One approach to this would be to try to find the start and ending bounds of the function and see if the IP resides in it. The star...

qt GUI connecting

I am just starting out with QT. I have read through some tutorials, and I think I have an understanding of signals and slots. I am writing a GUI that has various buttons that change the state of my main program. So for example in a drawing app, you would pick different drawing tools (using various buttons). What is the best way to go ab...

How to include directories in cmake generated visual studio projects?

I have (roughly) the following CMakeLists.txt project(Test) set(SOURCE 123.cpp 456.cpp ) find_package(Boost COMPONENTS unit_test_framework REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) message("${Boost_INCLUDE_DIRS}") add_executable(Tests ${SOURCE}) The message generated by message...

Performance penalty for using C++ vector instead of C array.

Is there a performance penalty for working with a vector from the standard library in C++ instead of arrays in C? ...

Class constructor with non-argument template type

For a normal C++ function, it's possible to have template parameters not appearing in the argument list: template<typename T> T default_construct() { return T(); } and call this with some_type x = default_construct<some_type>(); Even though the type I'm using is not in the argument list, I can still pass it to the function. Now...