mitrmkar 1,056 Posting Virtuoso

If you have LinkList::insert( const char * lib ); You have to use it with std::string like

while( getline( fin, lib, '\n' ) )
{
    game.insert( lib.c_str() ); // <- passes the data as const char *
    cout << lib;
}

Whether it really works as intended depends on what the insert() function actually does.

mitrmkar 1,056 Posting Virtuoso

SetPriorityClass takes the handle of the process, not the thread's handle. So you need to have

HANDLE hProcess = GetCurrentProcess();

Is there a utility to view threads and how they tick on and off of the processor?

You might use
Process Explorer

mitrmkar 1,056 Posting Virtuoso

ofstream nnewfile (textBox2->Text &".txt");

If you use VC 2008, you can convert textBox2->Text to std::string using
marshal_as

or with earlier versions, e.g.
http://msdn.microsoft.com/en-us/library/1b4az623.aspx

mitrmkar 1,056 Posting Virtuoso

You are not allocating enough storage, change from

prior = (double*) malloc(nzcwint);

to

prior = (double*) malloc(nzcwint * sizeof(double));

// + allocation of cwint in same fashion ...

Then again, why aren't you using new/delete, i.e.

prior = new double[nzcwint];
// etc
// and eventually ...
delete [] prior;

Then about conversions, stringstream is capable of doing the conversions you need. Consider ...

string test = "12301230 786345.94";
    long i;
    double d;
    stringstream sstrm;

    sstrm << test;

    if(sstrm >> i >> d)
    {
        cout << "i: " << i << "\nd: " << fixed << d;
    }
    else
    {
        cout << "Conversion error";
    }
mitrmkar 1,056 Posting Virtuoso

ParamValue must point to a large enough buffer to receive the information. The documentation should provide information wrt 'large enough buffer'.

You might use something like

const int GETMOVING_SIZE 1024;
char paramValue[GETMOVING_SIZE] = {0};

if(LT360LIB_CmdValue(handle, lt_GetMoving, paramValue))
{
    // here you can check the content of paramValue
}
mitrmkar 1,056 Posting Virtuoso

hey mitrmkar just a quick question ( sorry forgot to mention it before)
i get this warning when i add the header file of the lt360
( i removed the solved tag so the thread can be spotted and checked)

:\program files\microsoft visual studio\vc98\include\lt360lib.h(185) : warning C4518: 'LONGINT ' : storage-class or type specifier(s) unexpected here; ignored
e:\program files\microsoft visual studio\vc98\include\lt360lib.h(185) : warning C4230: anachronism used : modifiers/qualifiers interspersed, qualifier ignored

project.obj - 0 error(s), 2 warning(s)

as you can see no errors but warnings only ,but when i recompile the warnings go away and until now i had no problems.Is it ok to continue or are there some changes that must be done?

thanks

I assume you have a misplaced __stdcall somewhere in the header file, e.g.

extern "C" __stdcall LONGINT LT360LIB_OpenLinkUSB(void);

which has to be

extern "C" LONGINT __stdcall LT360LIB_OpenLinkUSB(void);
mitrmkar 1,056 Posting Virtuoso

I want the program to shut down on line 27 and lines 28-33 I am trying to make something so if anyone types a command that is not programmed it will display an error message

wrt lines 28-33, you need then change to

if (choice == 5)
        ;
    else
    [B]{[/B]
        system("cls");
        cout << "\n Error: Invalid Command";
        Sleep(2000);
        system("cls");
        AmasiVillage();
     [B]}[/B]

Note that you are still calling AmasiVillage() recursively, in case of invalid command.

mitrmkar 1,056 Posting Virtuoso

Looking at the main() ...

int main() 
{ 
   employee *emp;

   emp = new employee; // this is missing ...

   emp->getData();
...
mitrmkar 1,056 Posting Virtuoso

How about changing from

char fname[20], lname[20];

to

string fname; string lname;
mitrmkar 1,056 Posting Virtuoso
system("\"C:\\Documents and Settings\\myUser\\myProject\\app.exe\" -vb \"C:\\Documents and Settings\\myUser\\file.txt\"");

Try this one ..

system("\"\"C:\\Documents and Settings\\myUser\\myProject\\app.exe\" -vb \"C:\\Documents and Settings\\myUser\\file.txt\"\"");
mitrmkar 1,056 Posting Virtuoso

You increment i too early ...

emp1[i]->setProperties(emp_id,fname,lname,hours_worked,hourly_rate,employee_type_flag,given_gross_pay);

i++; // <- incremented too early
employee::headers();
// emp1[i] is not pointing to an allocated item at this point
emp1[i]->calc_gross_pay();

Note that you are not handling the case where employee_type_flag is something else than 's' or 'h'. There may be other errors too, I didn't look too closely, but fixing the getData() gets you started.

mitrmkar 1,056 Posting Virtuoso

You increment i too early ...

emp1[i]->setProperties(emp_id,fname,lname,hours_worked,hourly_rate,employee_type_flag,given_gross_pay);

i++; // <- incremented too early
employee::headers();
// emp1[i] is not pointing to an allocated item at this point
emp1[i]->calc_gross_pay();

Note that you are not handling the case where employee_type_flag is something else than 's' or 'h'.

mitrmkar 1,056 Posting Virtuoso
LT360LIB_Cmdvalue(handle,lt_goto_ccw,'nnn.n')

That's how a string is specified in Pascal. In C/C++ you have to stick with double quotes when you specify strings. Happy coding ...

mitrmkar 1,056 Posting Virtuoso

by the way one more thring if i create a .def file for a .dll and from the def file i found out that a certain function takes 3bytes e.g@3, is it ok to edit the .def file to make it take 4 (as we did) e.g changing the @3 to @4 or shouldn't i change the header file to suite the .dll needs

It appears that you are confused by the link ordinals in the .def files. If you take a look at the original .def file, there may be e.g a line like

LT360LIB_OpenLinkUSB         @2   ; LT360LIB_OpenLinkUSB

The '@2' is the ordinal which also can be used for linking, i.e. linking completely without the symbolic function name. So, don't modify/remove those ordinals, just append the function naming decoration to the function names, e.g.

LT360LIB_OpenLinkUSB[B]@0[/B]         @2   ; LT360LIB_OpenLinkUSB

and so on.


Now, as a check-list, using LT360LIB_OpenLinkUSB() as an example, things should look like:

In the header file:

extern "C" __stdcall LONGINT LT360LIB_OpenLinkUSB(void);

In the .def file

LT360LIB_OpenLinkUSB@0          @[I]<link ordinal>[/I]

In the generated .lib file: (use dumpbin /EXPORTS)

[I]<link ordinal>[/I]            _LT360LIB_OpenLinkUSB@0

And in the code

LONGINT val = LT360LIB_OpenLinkUSB();
mike issa commented: exactly the answer needed +2
mitrmkar 1,056 Posting Virtuoso

There must be no space between the function name and the '@', if there is, the meaning of the '@' + the following number changes to mean a 'link ordinal'.

So, use it as below ...

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink@4   
    LT360LIB_Cmd@8   
    LT360LIB_CmdIndexValue@10   
    LT360LIB_CmdString@4  
    LT360LIB_CmdValue@9   
    LT360LIB_GetDllVerDate@2   
    LT360LIB_GetUsbFirmwareVerDate@6   
    LT360LIB_LinkedCnt@0   
    LT360LIB_OpenLinkCOM@8   
    LT360LIB_OpenLinkUSB@0   
    LT360LIB_ReadBinary@17  
    LT360LIB_WriteBinary@17

just to make sure if the function takes no arguments @0

Yes.

and when i use

typedef unsigned char * Pointer;

pointer is equal to one byte right

No, it is 4, not 1 (you are dealing with a pointer).

i hope all the @value are correct

If in doubt about the sizes, you can check by e.g.

printf("%u\n",sizeof(unsigned char *));
mitrmkar 1,056 Posting Virtuoso

The .def file you are using is wrong.
Given the prototype extern "C" LONGBOOL __stdcall LT360LIB_CloseLink(LONGINT Handle); The counterpart entry in the .def file must be

LT360LIB_CloseLink@4

i.e. function name, followed by '@', followed by the number of the bytes (in decimal) the function's arguments use.

After you've gone through and fixed all the function's in the .def file, then use LIB.exe to generate a new .LIB.

mitrmkar 1,056 Posting Virtuoso

Post the output of the following command:

dumpbin /EXPORTS LT360LIB.lib


I guess the Pointer type is:

typedef unsigned char * Pointer;

and the LONGBOOL type is

typedef  int LONGBOOL;

Stressing again, try verifying these typedefs with the software vendor, so you don't have to be making guesses.

I think the header is otherwise OK.

mitrmkar 1,056 Posting Virtuoso

by the way when i created th lib file i got a .exp file what is it for?

.exp files contain information about exported items, used when your program both imports/exports from another one.

mitrmkar 1,056 Posting Virtuoso

Adding to what niek_e already mentioned, something like the following might be close to what you are after ...

for(double i = 0; i < 1.05; i += 0.05)
{
	this->Opacity = i;
	this->Refresh();
}

I am trying to "Fade In" a Form when this form is opened

Shouldn't it then be in the Form's Load event rather than in the Activated event?

mitrmkar 1,056 Posting Virtuoso

now the project its compiling and building i got errors when i used the __stdcall but when i removed it it worked

Sounds as there's still some sort of mismatch if it seems to work without __stdcall prototypes. If you get run-time errors (in debug builds) complaining about a failure to save ESP properly, then you'll have to revise and fix this import library generation. With release builds, you'll probably get access violation errors.

About the LONGBOOL, I guess that it might be actually


typedef int LONGBOOL;


Anyway, try to check those typedefs with the software vendor. (Who really should provide a ready-to-use package).

mitrmkar 1,056 Posting Virtuoso

I used a program called implib32 i created a.lib file directly from the dll and i linked it with my project but i got this error message
"
lt360.obj : error LNK2001: unresolved external symbol _LT360LIB_OpenLinkUSB
Debug/lt360.exe : fatal error LNK1120: 1 unresolved externals
"

At compile time, the LT360LIB_OpenLinkUSB() is apparently seen as __cdecl but it is __stdcall.
So you probably have been missing the step(s) to modify the header so that every function prototype is: extern "C" <return type> __stdcall function(<args>);

mitrmkar 1,056 Posting Virtuoso

You might use std::string find() to see if the line contains the search string.
And when it does, you can extract the rest of the line using std::string substr().

find()
substr()

mitrmkar 1,056 Posting Virtuoso

was created using borland are there any changes that must be done on it before using it in VC++

Just occurred to me that probably you'll have to do some changes before using LIB.exe. Apparently the .DLL functions use __stdcall calling convention, so you'll have to modify each function so that they'll conform to the MS's name decoration convention. In practice, every function is to be appended an '@', followed by the number of bytes taken by the arguments.

I.e. if you have a library function void __stdcall function(char *, char *, char *); it would be function@12 in the .def file.

Furthermore, in your project which will include the generated .lib + its accompanying header,
1) use extern "C" {} in the header file to wrap all the exported functions.
2) make sure that the exported functions are seen as __stdcall , either use the /Gz switch or explicitly add the __stdcall to each function prototype.

Note that LIB.exe will additionally prefix every function with an underscore. So if you'll look into the .LIB's exports by e.g. dumpbin.exe /EXPORTS LT360LIB.lib you'll see something like _LT360LIB_CloseLink@0 (assuming LT360LIB_CloseLink does not arguments)

If you end up having mixed-up calling conventions, your program will crash at run-time.

mitrmkar 1,056 Posting Virtuoso

hi all
i was a able to create a .def file from lt360lib.dll using Borland C++ (impdef.exe)

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink             @3   
    LT360LIB_Cmd                   @7   
    LT360LIB_CmdIndexValue         @9   
    LT360LIB_CmdString             @10  
    LT360LIB_CmdValue              @8   
    LT360LIB_GetDllVerDate         @1   
    LT360LIB_GetUsbFirmwareVerDate @6   
    LT360LIB_LinkedCnt             @2   
    LT360LIB_OpenLinkCOM           @5   
    LT360LIB_OpenLinkUSB           @4   
    LT360LIB_ReadBinary            @12  
    LT360LIB_WriteBinary           @11

how can i convert this .def into a .lib file.
I use Microsoft visual studio 6.0, and since it was created using borland are there any changes that must be done on it before using it in VC++

Assuming .def file name is LT360LIB.def, try MS's LIB utility as follows:

LIB /DEF:LT360LIB.def

mitrmkar 1,056 Posting Virtuoso

Thanks for the reply my friend
when i try to use

"e:\>bcf\bin\impdef lt360lib.dll > lt360lib.def"

i get this

"Syntax: IMPDEF [options] destname[.def] srcname[.dll]
Options:
-h Emit hints
"
and another question where should the output be located, is it in the same directory where the impdef.exe is located ?
i.e
"e:\>bcf\bin\lt360lib.def"
thanks again

I think dougy83 referred to another (somewhat simplified) impdef utility which you can find here
http://mirrors.zoreil.com/webclub.kcom.ne.jp/ma/colinp/gcc.html

So you might give that one a try, using the command:

impdef lt360lib.dll > lt360lib.def

mitrmkar 1,056 Posting Virtuoso

First of all, please learn to use code tags.

It looked like you are maybe implementing the functions inside main(), which is not allowed. You cannot nest any functions, it is strictly forbidden, like for example

int somefunction()
{
    int some_value;

   void nestedfunction()
   {
        // nestedfunction()'s code here ...
       return;
   }
    return some_value;
}

You can also do without function prototypes in some cases, for example

int somefunction()
{
    // somefunction()'s code here ...
    return 0;
}
int main()
{
     // call somefunction() ..
     int i = somefunction();
     return i;
}

Or the same with a prototype ...

// prototype
int somefunction();
int main()
{
     // calling somefunction() at this point can be done
     // because the above prototype tells the compiler 
     // how to deal with somefunction() ...
     int i = somefunction();
     return i;
}
// implementation
int somefunction()
{
    // somefunction()'s code here ...
    return 0;
}

Hopefully you got the main idea how to organize your code.

mitrmkar 1,056 Posting Virtuoso

The first time you print 'i', it has the initial unknown value it got from 'ch'.

If you add the green and red lines below, you'll probably get the idea ...

// morechar.cpp -- char and int types contrasted
#include <iostream>
int main()
{
        using namespace std;
        char ch;   //declare a variable ch

        // ch is not initialized to any known value ...
        cout << "uninitialized ch is: " << ch << endl;

        int i = ch;     // stores same code in an int

        cout << "i, being assigned the uninitialized value of ch, is: " << i << endl;

        cout << "Enter any ASCII character:\n";
        cin >> ch;
        // align i with ch ...
        i = ch;
        cout << " The ASCII code for " << ch << " is " << i << endl;

        cout << "Adding one to the character code takes you to the next character.\n";
        ch = ch + 1;    //change the character code in ch
		i = ch;
        cout << "The ASCII code for " << ch << " is " << i << endl;
        
        //using the cout.put member function to display a char
        cout << "Displaying  char ch using cout.put(ch): ";
        cout.put(ch);

        //using cout.put() to display a char constant
        cout.put('!');

        cout << endl << "done." << endl;
        return 0;
}
mitrmkar 1,056 Posting Virtuoso

Below you have three function prototypes ..

int hipvalley (void); 
int cricketvalley(void);
int ridgeangle(void);

You need to implement them too, i.e.

// implementation of function hipvalley () ...
int hipvalley (void)
{
    int some_value;

    // some code here

    return some_value;
}
mitrmkar 1,056 Posting Virtuoso

This is a modified version of niek_e's code

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
    ifstream in;
    in.open("c:\\yourfile.txt");
    if (!in.is_open()) 
    {
        cout << "Can't open file\n";
        return 1;
    }
    
    string line;

    // read one line at a time
    while (getline(in, line))
    {
        stringstream sstrm(line);
        
        string word1, word2;

        if(sstrm >> word1 >> word2)
        {
            // two words extracted ...
            MyFun(word1, word2);
        }
    }

    return 0;
}
mitrmkar 1,056 Posting Virtuoso

no numeric value activates my functions.

Two changes ...

# include "stdafx.h"
# include <iostream>
# include <cmath>
# include <xutility>
# include <stdlib.h>
# include <cctype>
# include <conio.h>
# define PI 3.1415926535898
using namespace std;

double Rise1 = 0; //for vertical data input of 1st roof slope-- Rise1
double Rise2 = 0; //for vertical data input of 2nd roof slope-- rise
double Eave = 0; //for data input- eave orientation angle-- 0 through 180,
		 // 181 through 360 is identical to 0 through 180.
double a; //input data conversion for both cricket, and hip/valley routine.
		 // cross product angle equation.
double Width = 0; //data input for cricket routine-  cricket width.
char  ch1, ch2, ch3; //character choices


float atan(float);
float acos(float);
float sqrt(float);

int hipvalley (void);//(float argc, char *argv[]); 
int cricketvalley(void);//(float argc, char *argv[]);
int ridgeangle(void);//(float argc, char *argv[]);


int main()
{
	
	for(;;) //this is an infinite loop. One of the choices
		    // will end it.
	{
		cout << "         Copyright 2001, Welcome to the Angle Finder Program.          " << endl;
		cout << "        This program is designed to take only numeric values.          " << endl;
		cout << "       Make certain you only input numbers. Otherwise it will exit.    " << endl;

		cout << " Please choose:  1 for the Hip/Valley Angle. "         << endl;
		cout << "                 2 for the Cricket Valley Angle. "     << endl;
		cout << "                 3 for the Ridge Angle "               << endl;
		cout << "                 0 to exit. "                        << endl; …
mitrmkar 1,056 Posting Virtuoso

I tried it, and recieved an error,

[Linker error] undefined reference to `WinMain@16'

You are trying to build a Win 32 GUI program and you have no WinMain(...) - hence the error.
If you want to build a GUI program, then write the WinMain(...) too, see
http://msdn.microsoft.com/en-us/library/ms633559.aspx

Otherwise, start a new Win32 Console Application project, which uses the int main() .

mitrmkar 1,056 Posting Virtuoso

How about adding a new member function, say SetStats(), which takes the user's choice and initializes a default constructed Character, i.e.

// default constructed
Character player;

cout <<"\n\nBefore we begin, please select your class."
	 <<"\nEnter a 'W' for Warrior or an 'M' for Mage. ";

char classChoice;
cin >> classChoice;

// initialize the player according to choice
player.SetStats(classChoice);

player.DisplayStats();

SetStats() might also validate the given choice and return true/false accordingly.

mitrmkar 1,056 Posting Virtuoso

What i want to do is write some of the rows of a report style CListCtrl with a color and other rows with another color, but if I switch the color with SetTextColor the color of the text in the entire control switches, i want it to switch just for the rows I set till the next color switch

Is this possible? If you know it is, plz enlighten me :)

thx a lot

This link might help
http://msdn.microsoft.com/en-us/library/ms364048(VS.80).aspx

mitrmkar 1,056 Posting Virtuoso

If you use the new operator on a class, say

class dummy { public: string f; };
int main(int argc, char *argv[]) {
  dummy *p = new dummy;
  return 0;
}

do you have to use the delete operator on p ? (since, apparently, it utilizes new.)

Yes, when you want to release that memory, 'delete' needs to be issued.

Salem commented: Yes indeed +17
mitrmkar 1,056 Posting Virtuoso

You might use std::string ...

string data;
string line;

while (getline(indata, line)) 
{
    data += line + '\n';
}
mitrmkar 1,056 Posting Virtuoso

a gets a negative value (-1) in the following loop.

// checks diagonal up-right movement
	for(a=i-1,b=j+1;a>=0, b<N;a--,b++) {
		if(board[a][b]==1) {

The comma operator a>=0, b<N is not doing what you probably expect.

mitrmkar 1,056 Posting Virtuoso

I tried to delete all the struct definitions and start over. I found when I use SceneParticulation, the error will be raised. Otherwise everything goes ok. But what's wrong in this definition:

struct SceneParticulation
{
public:
    SceneParticulation(){};
    ~SceneParticulation(){}; // here the program stops and fails
    ParticleSystem SPParticle;
};

Nothing is wrong with the definition as such, however, you also need to consider the member variable ParticleSystem SPParticle - what does that object hold and what will its destructor do. I think you should drop the habbit of memcpy'ing objects which are more than simple structs - simple meaning structs that only contain primitive types (int, char etc) and nothing else. I.e. instead of memcpy, write copy constructors/assignment operators where needed.

mitrmkar 1,056 Posting Virtuoso

If I use the [] operator and return a reference, is there any way to mark that indice when a value is assigned to it?

Maybe you could use a bitset for tracking the assignments.
Two things I noticed:
- use of realloc() would result in fewer malloc/free calls
- you should test malloc's return value against NULL

mitrmkar 1,056 Posting Virtuoso

Honestly, my compiler is not giving me these warnings! What compiler should I update to in order to get these messages?

Those are not compiler warnings but instead run-time checks wrt heap usage. The compiler will not catch the errors that occur in the program, but the run-time checks will alert you on the spot. Try e.g. a VC ++ Express 2008.

It appears that you are not yet fully understanding about memory allocation/deallocation, so
if you use the malloc/free, every pointer you 'free' must have been malloc'ed, no exceptions.
if you use the new/delete, every pointer you 'delete' must have been new'ed, no exceptions.

I'm also trying to say that if you have a non-dynamic 'object', you must not issue free nor delete on a pointer to such object. This in mind, go through the code and see what happens with e.g. [B]bound[/B] ("Bound"), [B]adephi[/B] ("Adephi"); .

mitrmkar 1,056 Posting Virtuoso

Thank you very much for the clarification.

I made the changes. Here are the files with the revisions.

Hmm, wouldn't it be better to drop usage of malloc()/free() since you are working with objects instead of raw native types i.e. consistently use new/delete. And maybe consider e.g. STL list for storing objects/object pointers, to save yourself the hassle of memory management.

Anyway, note that you must not issue free() on anything that has not been malloc'ed. That is just what is now happening in addObject(), that crashes the program at very early stages (before main() is called).

mitrmkar 1,056 Posting Virtuoso

Oh that's interesting. I was told to delete memory that was dynamically allocated and that malloc was one of the types that you could delete?

On a side note I'm using Dev-Cpp 4.9 and I haven't updated my compiler so I don't get those kind of warnings unfortunately.

Whenever you use malloc() then free the memory using free().
Whenever you use new, then free the memory using delete.

mitrmkar 1,056 Posting Virtuoso

After a quick look into it, I suggest that you get rid of malloc() usage. You are using 'delete' on memory that has been malloc'ed - that must not happen.
Then about 'delete', you only can delete something that has been allocated by 'new', consider

class a
{
public:
    a(){}

} instance; // an instance of class a

void somefunction(a* aptr)
{
    delete aptr;
}
int main()
{
    a * aptr = new a;

    somefunction(aptr);  // this is OK

    somefunction(&instance);    // <- must not happen

    return 0;
}

There were some other issues too, but I think first you could make sure that the basic memory operations are in order.
When I tried the program, addObject(adephi); causes the run-time to report damaged heap.

mitrmkar 1,056 Posting Virtuoso

okay, thats what I thought...so now I know I'm doing something wrong...I'm missing something somewhere, because I can't seem to pull the values from main and print them....now originally, I thought that was because I was screwing up the function that was supposed to print them to the screen...but maybe it's in the setters in my class, am I doing those wrong? (they are on the previous page)

You need to assign the values in the ctor (they do not get assigned automatically)

telnumber::telnumber (string i_npa,string i_nxx,string i_line)
: 
  npa (i_npa),
  nxx (i_nxx),
  line (i_line)
{ }
mitrmkar 1,056 Posting Virtuoso

what do the semi colon and the brackets do?

Those are just printable characters in the output simply for display purposes, i.e. the data of a single telnumber object would display on screen as:

npa: [ value_of_npa_here ]
nxx: [ value_of_nxx_here ]
line: [ value_of_line_here ]

They have no functional impact whatsoever.

mitrmkar 1,056 Posting Virtuoso

everything from about line 163 us what I want to output, but I can't seem to get it to do that.

everything I try is wrong in some way and won't even compile on the individual cpp files...and when hey do compile, I get the same blank lines

You need to devise something like ...

// telnumber
void telnumber::printtostream(ostream& out)
{
    // output npa, nxx and line
    out 
        << "npa: [" << npa << "]\n"
        << "nxx: [" << nxx << "]\n"
        << "line: [" << line << "]\n";
}
// worknumber
void worknumber::printtostream(ostream& out)
{
    // output the base class first ...
    telnumber::printtostream(out);

    // now worknumber data ...
    out << "name: [" << name << "]\n";
}
mitrmkar 1,056 Posting Virtuoso

Now you can tailor those functions so that the output is what you want it to be and in desired order. I.e. on a per-class basis decide what you want to output.

mitrmkar 1,056 Posting Virtuoso

I can't for the life of me figure out the implementation of those virtuals though, nothing I put in outputs anything from main except 172, 173, 177, 181, and 185. I need to figure out how to make it see the other lines as "inputs" to those functions and I don't know how to do that

Maybe the following helps ...

// telnumber
void telnumber::printtostream(ostream& out)
{
    out << "telnumber\n";
}

// worknumber
void worknumber::printtostream(ostream& out)
{
    telnumber::printtostream(out);
    out << "worknumber\n";
}

// billnumber
void billnumber::printtostream(ostream& out)
{
    worknumber::printtostream(out);
    out << "billnumber\n";
}
mitrmkar 1,056 Posting Virtuoso

Two simple examples, hopefully you'll get something figured out of those ...

class a
{
public:
    a(string s1, string s2){}
};
class b : public a
{
public:
    // default ctor
    b() : a("", "") {}

    // ctor with 4 strings
    b(string as1, string as2, string bs1, string bs2) : a(as1, as2) {}

    // ctor with 4 strings plus an int
    b(string as1, string as2, string bs1, string bs2, int bint) : a(as1, as2) {}
};
int main()
{
    b b1("asdf", "asdf", "asdf", "asdf");
    b b2("asdf", "asdf", "asdf", "asdf", 123);

    return 0;
}

The above changed so, that the 5 arg ctor has a default value for the integer argument, that way the 4 arg ctor can be dropped altogether ...

class a
{
public:
    a(string s1, string s2){}
};
class b : public a
{
public:
    // default ctor
    b() : a("", "") {}

    // ctor with 4 strings plus an int with default value zero
    b(string as1, string as2, string bs1, string bs2, int bint = 0) : a(as1, as2) {}
};
int main()
{
    b b1("asdf", "asdf", "asdf", "asdf");  // this one uses the default value
    b b2("asdf", "asdf", "asdf", "asdf", 123);

    return 0;
}
henpecked1 commented: very helpful without doing it for me +1
mitrmkar 1,056 Posting Virtuoso

Now parameter 4: it should be &adress of this string, amirite?

Basically a pointer (cast to void *) to anything you want the thread routine to receive via p_pVoid argument.

mitrmkar 1,056 Posting Virtuoso

but 'mkdir' is pure linux

Nope, Windows recognizes mkdir as well ;)