mitrmkar 1,056 Posting Virtuoso

Hmm ... reason is obvious, line 18 looks like

//size_t getAccountNumber()const;

so there really is no such function in the class. You have to uncomment that line to make it compile.

mitrmkar 1,056 Posting Virtuoso
int main() 
{
   // Before allocating any BankAccounts ... call srand() first
   srand(static_cast<unsigned int>(time(NULL)));

    BankAccount ba1, ba2;
    // see what account numbers were given ...
    cout << "Account: " << ba1.getAccountNumber() << "\n";
    cout << "Account: " << ba2.getAccountNumber() << "\n";

    return 0;
}
mitrmkar 1,056 Posting Virtuoso

Actually one of your posts says that "we leave the setAccountNumber out because this is generated when the BankAccount is created" <-> essentially this is what I suggested about using rand() in the constructor, so I think you might very well do it like that, i.e. simply

// constructor
BankAccount()
{
    // set the number here 
    mAccountNumber = rand();
}
mitrmkar 1,056 Posting Virtuoso

mAccountNumber is a member variable of BankAccount class, hence you need an instance of that class in the first place. So you might write something like

int main() 
{
    srand(static_cast<unsigned int>(time(NULL)));

    BankAccount ba;

    // given that the mAccountNumber were a public member variable,
    // the following assignment would work
    ba.mAccountNumber = rand();
    cout <<  ba.mAccountNumber;

    return 0;
}
mitrmkar 1,056 Posting Virtuoso

A short example, the rand() function is directly used in the constructor, and the
getAccountNumber() can now be const.
Note that you need to call srand() only once.

class BankAccount
{
public:
    // constructor
    BankAccount()
    {
        // set the number here 
        mAccountNumber = rand();
    }
    size_t getAccountNumber() [B]const [/B]{ return mAccountNumber; }
private:
 size_t mAccountNumber;
};

int  main()
{
    // seed the random number generator at the beginning of main()
    srand(static_cast<unsigned int>(time(NULL)));
    // rest of the program follows
}
mitrmkar 1,056 Posting Virtuoso

Hmm .. if you have a member function of a class declared as const, then you are not to modify the class instance's data. If you can cope with it, then fine. (I'm not fully following with what you wrote, sorry).

You might have a generateAccountNumber() which returns the generated new value that you can assign to a newly created account object and leave the const getBankAccountNumber() for just returning the pre-set account number.

mitrmkar 1,056 Posting Virtuoso

If you are going to set the value of mAccountNumber inside BankAccount::getAccountNumber(), then the function must be non-const, i.e. you need to have it like:

size_t BankAccount::getAccountNumber ()
{
     // set the value here ...
}
mitrmkar 1,056 Posting Virtuoso

A MSDN article
How to call a managed DLL from native Visual C++ code in Visual Studio.NET or in Visual Studio 2005
http://support.microsoft.com/kb/828736
It assumes that you have a managed DLL + a native application. (Hopefully this one is of more use than the previous one.)

mitrmkar 1,056 Posting Virtuoso

BCB version 3 is ancient, really consider updating to much more recent version, a full version is available for free, see http://cc.codegear.com/free/cppbuilder

To convince you, given that ThreadFunct1 is a member function of the form class, the following code ThreadHandle[0] = CreateThread(NULL, 0, ThreadFunct1, this, 0, &ThreadId[0]); should not even compile but apparently BCB3 happily accepts it.
The thread procedure you pass to CreateThread must be declared as: DWORD WINAPI ThreadProc(LPVOID lpParameter); meaning that you have to move the search function outside of your form class.

mitrmkar 1,056 Posting Virtuoso

I take it comes from the following

obj.vardas = vardas;
obj.pavarde = pavarde;
obj.adresas = adresas;

You can workaround this by

// pass a const char * to AnsiString::operator =
obj.vardas = vardas.c_str();  
obj.pavarde = pavarde.c_str();
obj.adresas = adresas.c_str();
mitrmkar 1,056 Posting Virtuoso

>> Why does the DLL did not get other values of the array??? I do not understand that.

You output to the very same memory address each calculation out[[B]0[/B]]=m_A[n+1]; // out[0] output from "C" to PSIM shouldn't you change that subscript to follow the for loop? So it would be out[n - 1]=m_A[n+1];

mitrmkar 1,056 Posting Virtuoso

Shouldn't you rather be calling the setType() through the DO pointer instead of BP (assuming that the Base class does not and is not intended to have a setType() method), i.e.
DO->setType("hello");
should work.

mitrmkar 1,056 Posting Virtuoso

I think the original findHighest() code was working quite well, to get the
actual highest score, simply use person[max].testScore once the index of the
highest score is known (i.e. max in this case), so ...

int findHighest(studentType person[])
{
	// assume highest score is at index 0
	int max = 0;

	for (int r = 1; r < numStudents; r++)
	{
		if (person[max].testScore < person[r].testScore)
		{
			max = r;
			// currently highest scored at index max now
		}
	}

	// Tell what we got: the index and the actual score
	cout << "highest score is at index: " 
		<< max 
		<< " and the score is: " 
		<< person[max].testScore;

	// return the index which can be used to subscript the person array
	return max; 
}
mitrmkar 1,056 Posting Virtuoso

If you need to copy a file, you can use System::IO::File::Copy()

mitrmkar 1,056 Posting Virtuoso
mitrmkar 1,056 Posting Virtuoso
...
// [B]MaritalType[/B] is undefined at this point
void extern displayStatus (MaritalType GrossType);
...
{);  // <-- remove that one
int extern getGross ();
mitrmkar 1,056 Posting Virtuoso

obj must NOT be const because you intend to modify it, so use only plain
gydytojas& obj i.e. friend fstream& operator>>(fstream& fs, gydytojas& obj)

mitrmkar 1,056 Posting Virtuoso

The #import directive with Dev C++ is not doing what you expect, practically it is the same as #pragma once i.e. related to include guards instead of type library imports. See e.g. http://www.delorie.com/gnu/docs/gcc/cpp_54.html

If you really want to tackle Office automation, you could switch from Dev C++ to a free edition of Visual C++ or Borland's C++ Builder to continue with.

As to your second question, I simply don't know of any good resources regarding Office automation & C++. Maybe google is a good bet to continue with.

mitrmkar 1,056 Posting Virtuoso

but what is wrong?

You are excluding the lower and upper bounds, so you could change to if ( i >= 65 && i <= 90 ) or if ( i > 64 && i < 91 ) The standard libraries provide functions for checking characters, see e.g. here
http://www.cplusplus.com/reference/clibrary/cctype/

mitrmkar 1,056 Posting Virtuoso

<<then the program will print to the result.txt A (last line ,transformed)
The reason why this happens is that the push() uses everytime the same buffer (=record), so effectively the stack contains pointers to this single buffer, and what was last written to the buffer, gets printed to the file as many times as pop() is called.

mitrmkar 1,056 Posting Virtuoso

In general about using feof to control a loop, please read this
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351

Then you might read my earlier post (above), you are not using the return value of fread() to specify how much data actually was read.

Lastly, please use code tags when you post code, instructions are given here
http://www.daniweb.com/forums/announcement118-3.html

mitrmkar 1,056 Posting Virtuoso

The client needs to specify how much data it sends, i.e. you have to use the value you get from fread(). The server must write only the amount it gets from recvfrom(). The return value of recvfrom() gives you that information. And last but not least, you must add error checking code, so that you not just blindly write/send something, for example, you have to check that recvfrom() is not returning an error or zero.
See the documentation for each of the functions you use, to figure out the correct error checking code.

mitrmkar 1,056 Posting Virtuoso

So for instance, if I have vector<int> vecList; as my vector and I want to replace vecList[5] with an integer entered by a user, how exactly can I do that?

Simply by vecList[5] = int_from_user; To lookup a value to change, you can use std::find()

#include <algorithm>
...
vector<int> v;
...
const int value = 234;
vector<int>::iterator srch = find(v.begin(), v.end(), value);

if(srch != v.end())
{
    // increment the value by one
    *srch = value + 1;
}
mitrmkar 1,056 Posting Virtuoso

I think you could start to tackle the problem by using fprintf() to write data to the file. Since you already know how to use printf(), it should be easy, see
http://www.cplusplus.com/reference/clibrary/cstdio/fprintf.html

After you've managed to get a record written to a file, the next step is to handle record deletions/insertions/changes.

mitrmkar 1,056 Posting Virtuoso

When I select 5 to quit and it asks if I'm sure, if I type "Y" it breaks and I get a window that says "Unhandled exception at 0x1029984f (msvcr90d.dll) in lab 10 FIX.exe: 0xC0000005: Access violation reading location 0x0000000a.

Change your message() function to following

void message(char *msg)
{
    printf("%s\n\n", msg); // <- asterisk preceding msg now removed
}
mitrmkar 1,056 Posting Virtuoso

You are missing using namespace System::Collections::Generic;

mitrmkar 1,056 Posting Virtuoso

any ideas?

This is bit vague but an idea anyhow, so here goes ...

Use EnumProcesses() to map process ids to executable names, that
gives you the process id of the target program. Then use EnumWindows() together with GetWindowThreadProcessId() to figure out the window handle you need to operate on.

Note however that EnumProcesses() is part of the process status helper api (psapi.dll) and may or may not be installed on a given system. I don't know whether MS distributes it as regular part of Windows these days. Moreover, if you are running as a restricted user, it may be that the user rights are not sufficient for getting all the data you need.

mitrmkar 1,056 Posting Virtuoso

Anyone interested in programs written in similar fashion can take look at here
http://www2.de.ioccc.org/years.html#2004

mitrmkar 1,056 Posting Virtuoso

The reason why it did not compile is that you still have arrays of Strings (vardas, pavarde and adresas), although in the previous post it appeared otherwise - hence the compiler rightfully complained "Structure required on left side of . or .*", when doing e.g. os << vardas.c_str() To fix it just use plain String variables as shown below...

struct gydytojas 
{
   String vardas; // [25];
   String pavarde; // [35];
   String adresas; // [50];

Those 3 lines above are the only ones you need to change.

mitrmkar 1,056 Posting Virtuoso

If ScheduledIn will be of type char (i.e. char ScheduledIn) then you cannot use double quotation marks in the if expression, use ' ' instead ...

char ScheduledIn;
...
ScheduledIn = toupper(SchecduledIn);
if (ScheduledIn == 'Y' || ScheduledIn == 'N'))
{

}
Ancient Dragon commented: You are right -- I should have caught that too :) +28
mitrmkar 1,056 Posting Virtuoso

If you cannot get it figured out, then zip the complete BCB project and post it here.

mitrmkar 1,056 Posting Virtuoso

I think you should forget trying to use a String to store and restore a color.
Instead, you can simply use a member variable of type System::Drawing::Color to save the original color and restore it back when necessary.

So in your Form class, add a member variable like; System::Drawing::Color ColorSaved; Then when you uncheck the checkbox, save the current color first

ColorSaved = textBox1->BackColor;
textBox1->BackColor = Color::Gray;

Then when you check the unchecked checkbox, restore the saved color textBox1->BackColor = ColorSaved;

mitrmkar 1,056 Posting Virtuoso

Sorry, it should be String^ NumberNew = gcnew String(Number1.str().[B]c_str()[/B]); stringstream::str() returns a std::string, hence that c_str() is needed there.

mitrmkar 1,056 Posting Virtuoso

So it seems that the decimals is dissapearing in the conversion.

atoi() converts a character string to an integer meaning that no decimal points are available. The stringstream is capable of doing the conversion, so you don't need to use any of the C-library conversion routines.

std::string Number3 = "0.31";
stringstream Number1(Number3);
double Convert;
Number1 >> Convert;
String^ NumberNew = gcnew String(Number1.str());
MessageBox::Show(NumberNew);
mitrmkar 1,056 Posting Virtuoso

Getting really confusing ...
given that line 210 contains "os << obj.vardas.c_str()" and actually produces the error message, does not make much sense, seems like the compiler would be completely unaware of the class itself. On the other hand, compiler errors can be quite misleading at times, so the initial reason may also be elsewhere.

Hmm .. you might as well try to see if specifying TForm1:: makes BCB happy (though I doubt it), i.e.

friend ostream& operator<<(ostream& os, const TForm1::gydytojas & obj)

mitrmkar 1,056 Posting Virtuoso

Hmm .. there were some severe errors that need to be fixed first (didn't notice those at first, sorry), byt anyway ..

friend ostream& operator<<(ostream& os, const gydytojas& obj)
{
         os << obj.vardas.c_str()  // need to add call to c_str() 
            << obj.pavarde.c_str() // because ostream knows nothing
            << obj.adresas.c_str() // about AnsiString
            << obj.gydid
            << obj.amzius
            << obj.specialyb
            << obj.telefonas
            << obj.asmkod  ;  // <- semicolon needed only here 

          return os;
}/* ; <- semicolon should not be here because this function is defined inside the gydytojas class */
mitrmkar 1,056 Posting Virtuoso

It might help if you post the code and the complete error message BCB gives.

mitrmkar 1,056 Posting Virtuoso
struct gydytojas {
    <snip>

  friend ostream& operator<<(ostream& os, const gydytojas& obj)
  {
      // In this function you have to write the data you want
      // in to the ostream os.

      // for example, write the integer values
      os << obj.gydid
          << obj.amzius
          << obj.specialyb
          << obj.telefonas
          << obj.asmkod;

      // All written ... return the stream object
      return os;
  };

  // You cannot pass a const gydytojas obj here,
  //  since you intend to load data into it
  friend fstream& operator>>(fstream& os, /*const */ gydytojas& obj)
   {
       // Todo: load the data ...
 
      return os;
     };
  };

I suspect that Salem has it right pointing out the String array usage, i.e. given that vardas actually translates to 'first name' (does it?), you should/could change it to
string vardas;
or
String vardas;
And the other variables alike too.

mitrmkar 1,056 Posting Virtuoso

What is the value of no_of_corners at the point where you do
CoordinateArray.resize(no_of_corners);
no_of_corners seems to be a member variable, I take that you are initializing it to zero before using it anywhere (?).

mitrmkar 1,056 Posting Virtuoso

Can anyone help me please

Try proceeding with posting e.g. the code you have written, an explanation of what is failing with it/what you perhaps don't understand, what the program should accomplish and so on.

mitrmkar 1,056 Posting Virtuoso

... so any other member function of this class who need this data can have the access of the data after this function call, without passing it as a parameter, is this correct?

Yes it is.

As I need the 2D vectors to be returned and used as inputs to some other functions from other classes, so is this the correct way of passing by reference: std::vector<std::vector<double> > & getRefMapInfo();
std::vector<std::vector<double> > & getRefCoordinateArray();

Yes, and if a function is not supposed to modify a vector it receives, you can use a const reference, e.g. function() receives the vector as read-only void function([B]const[/B] std::vector<std::vector<double> > & vect);

mitrmkar 1,056 Posting Virtuoso

Just a suggestion, have you considered using a struct/class the encapsulates the data of a single item? You could then operate with a vector of such struct/class instead of the many separate vectors you have now. E.g.

struct Item
{
    string ID;
    string Name;
    double Price;
};

void getData(ifstream& infile, vector < Item > & Items)
{
}

int main()
{
     vector < Item > Items;
     ifstream infile("file.txt");
     getData(infile, Items);
     return 0;
}
mitrmkar 1,056 Posting Virtuoso

Below is an arbitrary example, hope it gives some insight

#include <fstream>
#include <string>
using namespace std;

class MyClass
{
	string 	strings[2];
	int 	value;
	friend ostream & operator << (ostream & stream, const MyClass & obj);

public:
	MyClass(const string & s1, const string & s2, const int n)
	{
		strings[0] = s1;
		strings[1] = s2;
		value = n;
	}
};

ostream & operator << (ostream & stream, const MyClass & obj)
{
    // because this overload is a friend of MyClass,
    // the access to private class members is possible here

    // stuff in the two strings + the integer value, separated by tabs
	stream
		<< obj.strings[0]
		<< "\t"
		<< obj.strings[1]
		<< "\t"
		<< obj.value
		<< "\n";

	return stream;
}

int main()
{
	MyClass test("String #1", "String #2", 123);

	ofstream ofs("c:\\temp\\o.txt");	
	ofs << test;

	return 0;
}

You probably need to overload the ostream operator << for AnsiString too.

mitrmkar 1,056 Posting Virtuoso

An example is BestScanPositions.at(0) is 0 and BestScanPositions.at(1) is also 0. Then BestCols.at(0) is 19 and BestCols.at(1) is 16!!! Weird, eh?

Just guessing .. could it be that you actually do the 'offending' loop twice or more without clearing the vectors' content in between?

mitrmkar 1,056 Posting Virtuoso

Here is a thread about the books
http://www.daniweb.com/forums/thread70096.html

mitrmkar 1,056 Posting Virtuoso

codeproject has nothing else than copies of MSDN samples.

That just isn't quite true, you can convince yourself by taking a look, for example, in here
http://www.codeproject.com/KB/MFC/UltimateToolbox.aspx

mitrmkar 1,056 Posting Virtuoso

vardas is an array of 25 Strings. So if you want to keep it that way, you need to use
something like: gydmas[1].vardas[[B]some_valid_index_here[/B]] = Edit21->Text;

En1ro commented: Thanks for help ;) +1
mitrmkar 1,056 Posting Virtuoso
double Calc_Median(double median, double Size[])
{
        // You must use the effective count of items currently in the array,
        // instead of the constant MAX_SIZE
	median = Size[ MAX_SIZE / 2 ];
	return (median);
}
mitrmkar 1,056 Posting Virtuoso

There is one int -> double modification to do, you have
double index_of_smallest(const int Size[], int start_index, int number_used)
change it to
double index_of_smallest(const double Size[], int start_index, int number_used)

I think that should do it.

mitrmkar 1,056 Posting Virtuoso

>> all meaning the same thing obviously....is this something to do with my doubles??

That error comes when you try to do something like the following:

double anArray[100];
[B]double[/B] index = 0;
anArray[index] = 0.123;

The variable index cannot be of non-integral type (double, float), so you must change those four lines back and use int type for indexes. Just think of it, e.g Array[5.5984] does not make sense.