c++

I need a simple way to compile C++ code on a Mac intel, for the purpose of learning C++. I

I have a text book already and need a painless!! way to write and test the code ...

Opening a file through argv[1] C++ Question

Hi, I have check to see if the argument in argv[1] is valid for my file. i have a menu system in its own sub-routine called in main. Reading the file and so on is done in another sub-routine sepearte from the first, also called in main. How can i transfer the argv[1] to the first sub-routine? Or even the second? string sArgInit = ar...

RTD - making the sample COM DLL into a COM exe

I'm planning on making my existing application into an RTD server. The application is currently written in C++ and while I will eventually port it to C#/Mono I want to be able to add the RTD functionality with C++. I have found a few sample pieces of code (the MSVCRTDServer) and this site: http://weblogs.asp.net/kennykerr/archive/20...

c++ to functional

I am wondering how to do this in a functional programming language. Maybe f# or haskell. Can someone show me an example without using any function calls except for find and rfind? This function finds the next slash using i as the num of slash (<0 for backwards). size_t findSlash(const char *sz, size_t i) { std::string s = sz; s...

Creating a Maze class in C++ using 16bit unsigned int array?

I'm attempting to make a data structure to represent a Maze in C++. All the data I need to hold about the maze can be stored in 16 bit integers using bitwise operations (to represent each cell of the maze): 16 bit unsigned integer So, I figured a 2d array of 16bit integers and I'm good to go for my Maze data structure. I wanted to ke...

Should I become proficient with STL libraries before learning BOOST alternatives?

Does it make sense to restrict yourself to the STL libraries when learning C++ and then tackle boost and its additions after you have become fairly proficient with vanilla C++? Or should you dive right into BOOST while learning C++? ...

How to determine a process "virtual size" (WinXP)?

I have a program that needs a lot of memory, and it crashes as soon as the 2GB virtual address space is reached. Sysinternals process explorer displays this as "virtual size" column. How can I determine this "virtual size" with C (or C++) code? Ok, I have to query a performance counter for "Virtual Bytes". Perfmon shows the query stri...

Using ": number" while declaring variables

Hi All, If i declare an enum as follows: typedef enum A { a = 0x00000001, b = 0x00000002 } AObj; Now if i declare a variable of AObj as follows what does this mean? AObj myAObj : 2; ...

How do you include images as resources in a C++ executable?

Is it possible include images (jpegs) as resources in a win32 c++ executable? If so how? ...

Public boost::signal object

I make my boost::signals public because I'm lazy. class Button { public: signal<void()> clicked; }; int main() { Button btn; btn.clicked.connect(handleClick); } ... rather than encapsulating with a Button::OnClicked(boost::function<void()>). Is this going to come back and bite me? ...

Polymorphism across C++ and Ruby using SWIG

I use SWIG to wrap a Ruby script around a C++ library. In Ruby, I can inherit from a C++ class, but I cannot pass the resulting pointer to a C++ function in a polymorphic way. Here is a concrete example. The SWIG interface file defines base class Animal with virtual function sound(): [animals.i] %module(directors="1") animals %{ #i...

Preventing Virtual Method Implementation in C++

I have the following class hierarchy in C++: class Base { virtual void apply() = 0; }; class Derived : public Base { virtual void apply() { // implementation here that uses derived_specialty } virtual void derived_specialty() = 0; }; class Implementation : public Derived { virtual void derived_specialt...

Which Wiki Parser?

Does anyone know of a parser that can take Wiki formatted text as input and produce a tree of entities, in the same way that an XML parser produces an entity tree? To clarify, I'm looking for something that would take text like: -Intro- Textual stuff in ''italics'' --Subhead-- Yet more text and produce a tree rooted at Intro with ...

Difference between Dev C++ and Visual C++

What are the differences between Dev C++ and Visual C++? Dev C++ uses gcc, Visual C++ uses own compiler. Any others? Correct me if I'm wrong. I tried to compile a program written in Visual C++ with Dev C++ and it didn't work. Does anyone have any ideas why? ...

Not necessary to export class with only virtual/inline functions?

In C++ on Win32: Suppose I have a DLL with a header file that declares a class. The DLL exports some means of obtaining a pointer/reference to an instance of that class, such as a factory function. Am I correct in believing that it is not necessary to mark that class as exported using __declspec if one is only going to call virtual or...

vector<string> or vector<char *>?

Question: What is the difference between: vector<string> and vector<char *>? How would I pass a value of data type: string to a function, that specifically accepts: const char *? For instance: vector<string> args(argv, argv + argc); vector<string>::iterator i; void foo (const char *); //*i I understand using vector<cha...

Frustrating C++ compiler error regarding undefined references

So, this is problem a stupid mistake, but I've been hacking away at it for about an hour and can't seem to solve it. I have a class main.cpp which is full of random GUI crap (not really relevant to my problem I believe) but in one of my methods I make a reference to another one of my classes "TiffSpec" TiffSpec is a class I wrote and s...

Debug-compiled executable: Why not abort gracefully on invalid write to NULL?

What I don't understand about C/C++ is: Yes, everyone uses it to get blazingly fast executables, so they compile with optimization turned on. But for compilation with debug information turned on, we don't care about speed. So why not include more information in that compile mode, for example detect some segfaults before they happen? E...

C++ Pointer Snippet

Greetings everyone. This is my first question here at stackoverflow so please bear with me. My programming class this semester is Java; last semester was C++. My Java teacher feels (justifiably, I think) that it is very important for we students to understand the mechanics of memory management. Since Java has automatic garbage co...

Is it safe to `delete this`?

In my initial basic tests it is perfectly safe to do so. However, it has struck me that attempting to manipulate this later in a function that deletes this could be a runtime error. Is this true, and is it normally safe to delete this? or are there only certain cases wherein it is safe? ...