mitrmkar 1,056 Posting Virtuoso

One small/solid example that probably is what you are after is Using RegisterHotKey with MOD_NOREPEAT
Depending on your compiler/SDK, it might be that you are unable to use the MOD_NOREPEAT flag, in which case, just don't use that flag anywhere.

mitrmkar 1,056 Posting Virtuoso

>> About the delete: what's the problem with delete [] Index;
At one point, you had declared Index as

Entry * Index[100];

i.e. not dynamically allocated and hence impossible to be delete [] d.

>> To answer your question I'm using Entry **Index thus the delete [] Index
That's OK then.

But delete [] Index[i] looks bad. If Index[i] is a pointer to a single instance of Entry, you must do delete Index[i] instead.

All in all, you seem to be having serious dynamic memory management issues (that's when the strangest things start to happen), I hope you get those solved. And if you get tired and weary solving these problems, maybe post back (with code that compiles + the input files).

mitrmkar 1,056 Posting Virtuoso

>> If I use Entry *Index[100];
Assuming the destructor still looks like

Dictionnaire::~Dictionnaire(){
	for(int i = 0; i < indiceCourant; i++){
		delete Index[i];
	}
	delete [] Index;
}

delete [] is guaranteed not to work, so rather use Entry ** Index or otherwise remove delete [] Index altogether.

Then there is this Dictionnaire::effacer() which duplicates what the destructor is doing. This is a somewhat suspicious construct, because if both of these methods are in effect, you'll be double-freeing memory, which you must not do.

Perhaps post the latest code (that compiles) and the input files that you are using.

mitrmkar 1,056 Posting Virtuoso

The if-statements there are fundamentally plain wrong.
If you write ..

if (ValueRead ==  'A' || 'a')

that evaluates to

if (ValueRead ==  'A' || true)

which is always true -> counter is incremented.

So, you want to write the if-statements like ..

if (ValueRead ==  'A' || ValueRead == 'a')
  counter ++;
else if ...

Furthermore, Dave Sinkula ^^^ pointed out that it is generally not a good idea to use .eof() in a loop control and gave you a good alternative. Maybe pay attention to his suggestion.

mitrmkar 1,056 Posting Virtuoso

One thing to check, are you absolutely sure that the NodeItem.cpp is included in the compilation?

Have you taken a look at C++ FAQ What does it mean that the "virtual table" is an unresolved external?

mitrmkar 1,056 Posting Virtuoso

The compiler will not allow access. I know I am overlooking something.

You have to pay attention to the method signatures. The class declaration has

// returns a reference to a Fraction, and takes in a reference 
// to Fraction
friend Fraction & operator + (Fraction & c);

That is different from what you are trying to implement, which is;

// returns a Fraction, and takes in a Fraction
Fraction operator + (Fraction c);
mitrmkar 1,056 Posting Virtuoso

I had a similar problem with my program crashing earlier, see http://www.daniweb.com/forums/thread263455.html and i was advised to do this...is it not correct?

Jonsca already pretty much explained your current situation, but I still try to clearly point out what is wrong below ...

Matrix::Matrix(int rows, int cols)
{
// Here you are assigning the member variables mdim_ and ndim_
// to [I]themselves[/I]. It is of no practical use whatsoever.
mdim_ = mdim_;
ndim_ = ndim_;
// So simply delete the above two lines

// What is below is OK. Now you are initializing the Matrix object's
// dimensions in a proper way.
mdim_ = rows;
ndim_ = cols;

In the thread that you linked, the 'this' pointer was used in the constructor to make the code more readable (because the constructor's arguments where named identically to the actual member variables (mdim_ an ndim_), which is confusing).

mitrmkar 1,056 Posting Virtuoso
#include <stdio.h>
#include <stdlib.h>

int main(){

    char option, factor;

    printf("Choose your operator: \"+\" ; \"-\" ; \"*\" ; \"/\" \n>\t");
    scanf(" %c", &option);
    printf("You chose : %c \nChoose your factor:\n>\t", option);
    scanf("%d", &factor);
    printf("You chose : %i\n",factor); 
    printf(" %c", option);
    
    if(option=='+'){
        printf("It's WORKING!");
        system("pause");
    }

    return 0;
}

It looks like the problem would be that factor is of type char , but when you do the scanf(...) , you tell to input an integer (i.e. "%d") instead of char . So, scanf() happily accepts anything that fits into an int , and because an int consumes more memory than a char , you will end up overwriting stack memory - and that changes the value of option .

You might add; printf("option is now [%c]", option); there, so that you see that the value has changed.

So you might remedy this by ..

int main(){

  char option;
  // 'factor' changed to int instead of char ...
  int factor;
  // .. and the rest of the code as is ...

I hope that made some sense. At any rate, you don't want to use mismatched/erroneous format strings with any of the scanf/printf -family functions.

PS. hint: GCC is quite good at pointing out mismatched format strings.

jonsca commented: Another good catch +2
mitrmkar 1,056 Posting Virtuoso

COuld any one help me in solving tis issue?

If you had posted the code using code tags, the code would probably be readable. Now it is not. Perhaps see
What are code tags?.

Salem commented: It's too unreadable for me to even care, even with code tags +19
mitrmkar 1,056 Posting Virtuoso

Just in case you don't know about illegal filenames, see
Filename / Reserved characters and words

So having a filename containing e.g. semicolon(s), would quite likely be a mission impossible.

mitrmkar 1,056 Posting Virtuoso

Arrival.h:7: error: expected class-name before ‘{’ token

#ifndef ARRIVAL_H
#define ARRIVAL_H

#include "Event.h"

using namespace std;

Most likely you are not including anything from the std namespace via the Event .h, so the namespace std remains unknown to the compiler and cannot be used there. I.e. perhaps remove the using namespace std; altogether, (if there will be no use for it in that header file). Otherwise, #include the necessary headers and you'll be able to keep the rest of this header file as is.

mitrmkar 1,056 Posting Virtuoso

I have tried that but this does not produce an output on the screen. I always seem to have to use the newline character (\n) in order to get anything.

Have you tried fflush(stdout); ?

mitrmkar 1,056 Posting Virtuoso

plz i want to know information about class libraries in C C++ Java .i want to know about History,how they work , etc

That's a rather broad question to be answered (don't you think?), so maybe start for example here.

mitrmkar 1,056 Posting Virtuoso

I need help with reading each letter at a time

To access each character of a std::string one at the time, you can use the operator []

string s = "abcdefg";
  for(size_t ii = 0; ii < s.length(); ++ii)
  {
    cout << "s[ii]: " << s[ii] << endl;
  }

>> I am trying to make a function that will read each letter of the word and count the vowels that are right next to each other.
Good idea.

>> Once it find a consonant it will send that word to a separate counter
Be sure to check the whole string, i.e. don't stop at encountering the first consonant.

mitrmkar 1,056 Posting Virtuoso

After the failed attempt to open the file, inFile is in error state. You want to do inFile.clear(); to make it functional again.

mitrmkar 1,056 Posting Virtuoso

fprintf() takes a FILE * as its first argument (which would be in your case the variable customer ).

Then your logic is backwards, in the sense that if the file is opened succesfully, you inform the user about it. But if the opening of the file fails, you'll be trying to write to the file.

And last but certainly not the least, please use code tags when you post code.

mitrmkar 1,056 Posting Virtuoso

Can you please explain what you meant by "> program.exe 123 456"?

Actually, there are two arguments

Actually there are three, from the program's point of view, that is. The name of the program itself counts as one argument. Aia pointed that out ^^ but I think you missed it. So, given that you run the program as follows:

program.exe 123 456

then your program sees ..

argv[0] -> "program.exe"
argv[1] -> "123"
argv[2] -> "456"

and argc would be equal to three.

mitrmkar 1,056 Posting Virtuoso

?Invalid number of arguments
Press any key to continue . . .

int main(int argc, char **argv)
{
    if (argc != 3)
    {
        printf("?Invalid number of arguments\n");
        system("pause");
        exit(1);
    }
}

Well, it is expecting to be run with 2 arguments, if those arguments are not present on the commandline, the program just exits with the message.

So try using it like:

> program.exe 123 456

It seems to be expecting strings that atoi() converts to integers.

mitrmkar 1,056 Posting Virtuoso

I am not able to change anything in the header file, so is there a way to initalize these variables within the .cpp file?

Yes, there is. For example,

Matrix::Matrix(int mdim_, int ndim_)
{
  this->mdim_ = mdim_;
  this->ndim_ = ndim_;

You could/should also change to ..

Matrix::Matrix(int [I]rows[/I], int [I]cols[/I])
{
  mdim_ = rows;
  ndim_ = cols;

That would be more clear, as it is quite confusing when the incoming arguments are named exactly as the member variables.

And furthermore, given a matrix class, sticking to variable names in terms of rows/columns would be more readable (i.e. instead of mdim_/ndim_ and also plain m and n elsewhere in the code).

Note that you have to fix both constructors so that the dimensions are stored properly upon construction.

mitrmkar 1,056 Posting Virtuoso

Wow...
I just gave some codes to show what i thought

OK, but you see, I really did not understand whether you were asking a question or what, but since you weren't, then it's all OK by me :)

mitrmkar 1,056 Posting Virtuoso

Bloodshed Dev C++.

Bloodshed Dev C++ is actually the IDE, i.e not a compiler. Perhaps you are using MingW's GCC?

mitrmkar 1,056 Posting Virtuoso

You defined the virtual generator function,I think it is illegal in C++ grammar
The sixth line and twelfth line

No, it is certainly not so i.e. a virtual destructor is perfectly legal.

mitrmkar 1,056 Posting Virtuoso

In the main function,you've gotten the object of class A,why still choose the static variable.

If you go through estevemd's posts, maybe you get the main idea of what's been shown above. I.e. that it is possible to have a private static (<- because estevemd rather has it that way) member variable, which can be accessed by another class' member method.

Then, sorry but I don't actually quite understand are you asking a question or demonstrating something (or both)?

mitrmkar 1,056 Posting Virtuoso

Can this Static variable be a pointer?

Yes it can. About small tutorials, I'd bet that you'll find reasonable ones by searching the web for example "static member variable in c++".

mitrmkar 1,056 Posting Virtuoso

can I use combination of static variable and friend function to expose that variable to only one method of another class?

Yes you can, like so ..

#include<iostream>
using namespace std;

// forward declaration
class A;
class B
{
public:
  B(){}
  void set(int ii);
};

class A
{
  // 'shared_value' is common to all instances
  // of class A because it is 'static'
  static int shared_value;

public:
  A(){}

  void print()
  {
    // Display the current value
    cout << "A::shared_value = " << shared_value << endl;
  }

  // only B::set(int ii) is granted access
  friend void B::set(int ii);
};

// Upon program start-up, initialize ..
int A::shared_value = 0;

void B::set(int ii)
{
  // Modify the A class' private value
  A::shared_value = ii;
}

int main()
{
  A a1;
  B b;

  // The initial value should be 0 ..
  a1.print();

  // Change the A's data through B
  b.set(42);

  // The new value is .. 
  a1.print();

  A a2;

  // a2 shares the value with a1 ..
  a2.print();

  cin.get();
}
mitrmkar 1,056 Posting Virtuoso

So can you explain a little bit on Static thing?

Essentially a static member variable (be it of any type) is a variable that is common to all non-static instances of the class.
Maybe the following explains it a bit ..

#include<iostream>
using namespace std;

// forward declaration
class B;

class A
{
  // 'shared_value' is common to all instances
  // of class A because it is 'static'
  static int shared_value;

public:
  A(){}

  void print()
  {
    // Display the current value
    cout << "A::shared_value = " << shared_value << endl;
  }

  // class B is granted access
  friend B;
};

class B
{
public:
  B(){}

  void set(int ii)
  {
    // Modify the A class' private value
    A::shared_value = ii;
  }
};

// Upon program start-up, initialize ..
int A::shared_value = 0;

int main()
{
  A a1;
  B b;

  // The initial value should be 0 ..
  a1.print();

  // Change the A's data through B
  b.set(42);

  // The new value is .. 
  a1.print();

  A a2;

  // a2 shares the value with a1 ..
  a2.print();

  cin.get();
}
mitrmkar 1,056 Posting Virtuoso

If the private data is static, i.e. all instances of the class share the static private data, then there is no need for the class object as an argument.

If the private data is non-static, then you must have the class object as an argument because the object instance actually contains the data.

mitrmkar 1,056 Posting Virtuoso

A couple of suggestions;

  • Maybe change the signature of int mv(...) to void mv(...) Currently you have the function returning a value, which is completely ignored by the main() function, hence serving no practical use. And in case of errors, you throw exceptions, which makes the 'return -1;' statements to be of no use.
  • You could also check that the file is correctly copied before it gets deleted. As of now, there is no checking against that kind of failure.
mitrmkar 1,056 Posting Virtuoso

Line 40

Since tree_node is nested inside the BinarySearchTree class, you need to apply the scope resolution operator ..

[B]BinarySearchTree[/B]::tree_node * BinarySearchTree::inorderSuccessor(tree_node* p ){}

or make the declaration of tree_node public and use a typedef ..

typedef BinarySearchTree::tree_node treeNode;
treeNode * BinarySearchTree::inorderSuccessor2(tree_node* p ){}
mitrmkar 1,056 Posting Virtuoso

Perhaps you could post the code you've tried?

mitrmkar 1,056 Posting Virtuoso

Two options to make this sort(...) work, would be

Make the fooSort() a static member function, so ..

[I]static[/I] bool fooSort(const Foo * fooPointer1, const Foo * fooPointer2)
    {
        return fooPointer1->fooMember1 < fooPointer2->fooMember2;
    }

or take the fooSort() function outside of the class completely, so ..

bool fooSort(const Foo * fooPointer1, const Foo * fooPointer2)
{
    return fooPointer1->fooMember1 < fooPointer2->fooMember2;
}

The above is based on what you posted in your initial post. But I hope you get the idea.
Then a couple of things..
- there is a member variable Random [I]rand[/I] , that is bad, since the standard library comes with a routine named rand() , so try to avoid name clashes.
- You are typing in extra semicolons as in

void setFooMemberValues()
{
<snip>
} ;

Depending on the mode you compile with GCC, your code might be totally rejected.

Then you asked what is wrong with the following ..

std::vector<Foo*> fooObjectPointers1;
std::vector<Foo*> fooObjectPointers2;
// The vectors contain nothing at this point, trying to access
// the non-existent element causes the crash
fooObjectPointers2[0] = fooObjectPointer1[0];

A safer way to try to access would be fooObjectPointers2.at(0) , which would give you an exception that could be caught.

mitrmkar 1,056 Posting Virtuoso

I replaced the Cin>> with system("pause") and system ("CLS") and still have the same issues but when they are removed the pointer is passed to the display class correctly.

The int Signal[280]; being local to the FileFunc::LoadFile() function is a guaranteed source of trouble for you. You may detect correct'ish-like behaviour to some extent by rearranging your code, but as long as the array is local to FileFunc::LoadFile() , you are simply wasting your time trying to get the thing work.

mitrmkar 1,056 Posting Virtuoso

One thing to note, you have had there a simple out-of-bounds write

// 'n + 1' elements -> last valid index is 'n', not n + 1 
  double * coeff = new double[ n + 1 ];

  for(int i= n + 1 ;i>=0;i--)
    // here it would go wrong when i == n + 1 ... 
    cin>>coef[i];
jonsca commented: Good catch. +2
mitrmkar 1,056 Posting Virtuoso

//when I delete root node from bst

line 29: declares tree_node* parent (and leaves it uninitialized)

Then, if the root node will be a match for the data you search for, you end up using the uninitialized pointer from line 44 onwards.

mitrmkar 1,056 Posting Virtuoso

One option would be to read in one character at the time, using e.g. fgetc(), filtering out the unwanted characters. To write to output file, you'd probably like to use the counterpart putc() .

This would narrow down the task at hand, which might be a good idea given your 5 days of programming experience.

mitrmkar 1,056 Posting Virtuoso

>>so is there anyway of getting around this virtualized registry problem

I don't know a good answer to that one (sorry). I think the User Account Control plays a role in this one too, perhaps try reading Microsoft's documentation on the subject and see what you can make of it.

As to the not yet found key that you've got there, try locating the
HKEY_USERS\<User SID>_Classes\VirtualStore\Machine\Software
key. I bet you'll find it there.

Then again, this is just a Windows feature, that you can 'ignore' i.e. as long as you have sufficient user rights/privileges, you'll be able to write under HKEY_LOCAL_MACHINE and read from there. In other words, at the end of the day, it should not matter to you where the data physically resides in the registry (hope you get the point).

>> or will i just have to live with it?
As a conclusion, since you are on Windows 7, you have to live with it in one way or another...

[EDIT]
If you want to know your account's SID, visit www.sysinternals.com and get yourself an utility called "psgetsid.exe".

mitrmkar 1,056 Posting Virtuoso

Windows 7, i've created a registry key before, and it has showed up in regedit before. And yeah i refresh regedit, and reopen it, still no key shows up.

Since Windows XP the registry has been partly virtualized i.e. portions of it actually map to elsewhere as compared to the desired location. So, keys under HKEY_LOCAL_MACHINE are subject to this, so that may be a concern here (i.e. you may be looking in the wrong place in the registry, I'm not absolutely sure though).

Anyway, you being on Windows 7, I'd suggest that you try to create the key under HKEY_CURRENT_USER and see if it makes difference (there should be no virtualization issues there).

mitrmkar 1,056 Posting Virtuoso

I run it again and it opens the key, however i still can't see this key in regedit, after restarting the program multiple times and refreshing.

If you don't see your program output the "Checking for config failed" text, then the key is in the registry, in other words the code uses RegCreateKeyEx() properly. By refreshing, you mean refreshing the Registry Editor's view (i.e. F5)?

Which Windows version you are using?

mitrmkar 1,056 Posting Virtuoso

Which error?
Only thing that I see missing, is a header file for getch(); .

Whoops, it is also lacking the implementation of constructor/destructors.

mitrmkar 1,056 Posting Virtuoso

This code gives compile time error but I am unable to understand the reason.

Which error?
Only thing that I see missing, is a header file for getch(); .

[EDIT]
Oh, and it leaks memory ;)

mitrmkar 1,056 Posting Virtuoso

It looks like you are doing whole lot of extra work there. In addition the code also leaks memory, you allocate using new , but never delete that memory. Remember that you must delete the memory you have allocated.

If your RWCString class is the RogueWave's string class, then you can simplify the code a lot. That class supports e.g. operator == , so I'd suggest that you try the following and post back.

Employee * Employee::readEmpInfo(const char* nickname) {

  std::map<int, Employee*>iterator myptr;

  for(myptr = myEmpData.begin(); myptr != myEmpData.end(); myptr++) 
  {
    // temp variable 'employee' used here to make code more readable
    Employee * employee = (*myPtr).second;

    // RWCString has built-in capability to directly
    // compare against a 'const char *', so use it ...
    if(employee->emp_first_name == nickname)
    {
      cout << "found the employee you are searching for :" 
           << employee->emp_first_name << endl;
    }
  }
}

Then, would you please tell which compiler you are using? The code you've posted really should not compile in the first place. So I'm wondering whether your compiler is quite broken or are you posting somewhat irrelevant code snippets.

PS. Note that at any rate, you don't need to allocate ( new ) any memory inside that function.

mitrmkar 1,056 Posting Virtuoso

I don't want to declare child as pointer. Is this possible to keep it as array instead of pointer?

A bit unclear to me will you be writing C or C++. But anyway, if C++ is allowed, you might store the child nodes in a std::vector, so ..

struct node
{
  std::vector<node> child;
};

the problem is with structure which is very much C

Hmm, a structure is just as much about C as it is about C++, so I suppose no 'admin' would kick you anywhere.

mitrmkar 1,056 Posting Virtuoso

When you have a static non-const member variable, it also needs definition outside the class declaration, so you need to have it like

<snip>
class HotDogStand
{
public:
		void JustSold();
		int Cart;
		int IdNumber;
		int SalesToday;
		int TotalSales;
		int IncrementalSale;
		static int DogCounter;
};

// definition here, outside the class
int HotDogStand::DogCounter = 0;
mitrmkar 1,056 Posting Virtuoso

Adding to what's been said above, GCC spotted a thing in the list() function, it said;

warning: too many arguments for format

That means that the printf(...) call there needs attention. There is a mismatch between the format string and the number of arguments you actually pass in.

Then you might consider dropping usage of fflush(stdin) altogether (as it might produce quite unexpected results), and perhaps replace gets() with e.g. fgets() to be on the safer side.

See ...
Why gets() is bad.
Why fflush(stdin) is bad.

Salem commented: Many fine points that deserved better than an anonymous -1 for your effort +19
mitrmkar 1,056 Posting Virtuoso

good points

Oh well, the OP is at the moment quite confused about pretty much everything, but let's just wait and see if he returns and is able to tell what this is all about (I'm still not ruling out that linker/object file- 'thing' ...).

mitrmkar 1,056 Posting Virtuoso

Where are you getting this?

Help w/ what goes in c++ header file

I would assume that there is at least one header file,
most likely including function declarations for this assignment.

... and how the library and linker come into play with programming.

To me this implies that there would be more than one .cpp file
involved, demonstrating how e.g. two object files are used to produce an executable (unless this assignment is the first step to that, i.e. with one .h + one .cpp, which will be expanded upon later on)

@OP
Could you provide somewhat more detailed general description about this assignment?

mitrmkar 1,056 Posting Virtuoso

.cpp files? even for such a short program?

As far as I understood, this seems to be partly about having multiple files in your project, hence two .cpp files plus a header.

Have yourself main.cpp, which comes with the main() function implementation and #includes the header file (.h). The header file declares the functions that you end up writing in the third file, which is the other .cpp file.

Then figure out, how to put these files together in order to compile and link a working executable. If you are allowed to use an IDE, it should be quite easy, if not, it might be little more trickier.

ARRGHH!

LOL, relax.

[EDIT] [B]int [/B]main() is a valid signature for main() , just stick with that in this assignment.

mitrmkar 1,056 Posting Virtuoso

Another issue: I draw the picture not directly on the Form, but on the Panel. The DoubleBuffering property is protected here :(

You might derive from Panel class and use the derived class as your Panel with DoubleBuffering enabled. Lukezzz was doing the same thing here. Though it seemed that the double-buffering did not help him too much, then again, he has 200 buttons on that derived Panel (which is a lot of buttons) and your situation might be very different.

mitrmkar 1,056 Posting Virtuoso

I think this might be related to the file's content. Try saving the following numbers to your file (with e.g. Notepad) and see if it makes a difference.

1 2 3

mitrmkar 1,056 Posting Virtuoso

in a Borland compiler WCS can be used as a function which returns a pointer to a memory that is deleted automatically at the end of block.

After reading that, it just occurred to me, that maybe you've been 'digging in too deep too long', so that you've actually forgotten that a regular stack-based object tends to do that thing, could it be?