JasonHippy 739 Practically a Master Poster

Oh hang on... looking at your original post again, you said version 8 not VS2008. Version 8 is VS2005 isn't it?!

Doh! Sorry, if you're using VS2005, disregard my previous post entirely...

Well, almost entirely! It might be worth making sure that you've got all of the relevant service packs installed for the VS2005 IDE.
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hmm, this problem sounds interesting...
I've just been upgraded to VS2008 Pro, from VS2003 Pro at work and it's been great so far. The ability to see inside std library containers from the debugger without having to add code to log values has been most welcome.

VS2003's debugger was a royal pain in the posterior when it came to seeing what was inside std::library classes, I resorted to using my own logging class to log the details of objects stored in std:: containers.

Anyway, we use some pretty complicated class structures and objects in our product (3D CAD/CAM) and I've not seen any problems with the debugger so far. I'm in the middle of updating/re-implementing some old legacy code at the moment, so I'm going to be using the debugger rather heavily soon enough. I'll keep an eye out for any problems and repost if I spot anything unusual.

Just a thought, and this may sound like a stupid question; but do you have service pack 1 for VS2008 installed? We patched all of our installs to SP1 when we installed VS2008, so none of my dev team have tried it without the service pack.

If you've already got SP1 installed, then I'm out of ideas I'm afraid. I'll keep an eye out, but I've not seen any problems with the debugger yet. None of the other members of my development team have reported any odd behaviour from the debugger either.

However, if you …

JasonHippy 739 Practically a Master Poster

Can you include a little bit more detail? Perhaps also some relevant code?
If you could at least post the relevant bits from your .h and .cpp file it would be very helpful to actually see things in context and make it easier to diagnose the problem.

As it stands there isn't really enough info in your post to allow anybody to help you particularly well.

Offhand, the errors about set and string could possibly be because you've perhaps forgotten to #include the headers for set and string in your header file (or maybe you could forward declare set and string and then #include their headers in your .cpp file).
Other than that, I'm not sure how much help we can be ATM.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Add a variable called something like leading_spaces and set it to 0 as per my algo, then inside your main loop, if the number of spaces is greater than 0, set up a loop to output the appropriate number of spaces.
After the loop to output the spaces you'll have your loop to output the rest of the line (i.e. the count-down).
Towards the end of the main loop, increment the number of spaces ready for the next iteration of the main loop.

So if you've followed my algo correctly, you should have something that looks a bit like this:

#include <iostream>

int main()
{
	int num=0;
	// your code to get user input here....
	...

	// set initial values for minimum and the number of leading spaces
	int minimum = 1;
	int leading_spaces=0;

	// loop until minimum is greater than the entered number.
	while(minimum<=num)
	{
		// display any leading spaces
		if(leading_spaces>0)
		{
			for(int s=0; s<leading_spaces; ++s)
				std::cout << " ";
		}
		
		// your loop to count down and output values from num to minimum to go here....
		...

		// terminate the current line
		std::cout << std::endl;

		// increment minimum and leading_spaces
		minimum++;
		leading_spaces++;
	}
	std::cout << std::endl;
	return 0;
}

Note: I've deliberately left out the code for getting user input and the code for outputting the numbers. You've already got that by the sounds of it..

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Oh yeah, good point kesh...Looking at my previous post, I forgot to include a bit about the leading spaces in the output. (My bad, I spotted it when writing my original post, but completely forgot to include it in my description! Very careless of me!)

@OP:
If you look at your desired output, the first line has no leading space, the 2nd has one leading space, the 3rd has two etc.etc. .
So you can see that for each additional line you output, you will need an additional space.
So you start with 0 leading spaces.
Before you use the loop to count down and output the values from n to minimum, you'll need to use another loop to output the required number of spaces.
After outputting each line you'll need to increment the number of spaces.

In light of my glaring omission, I'll give you some pseudo code for the solution! What the hell I'm feeling generous...

In pseudo code, your algorithm should be something like this:

1. Input a number (num) between 1 and 10
(NOTE: Don't forget to do any error checking, prompt user until they enter something valid)
2. Set minimum value to 1
3. Set number of Leading spaces to 0
4. While minimum is <= to num:
Do the following:
(i). if leading spaces > 0: use a loop to output the required number of spaces.
(ii). Using another …

JasonHippy 739 Practically a Master Poster

Storing marks in your class as an int rather than a reference to an int would be the simplest way of solving the problem.

Once assigned, a reference cannot be re-assigned and that is the cause of your problem here. In your copy constructor, you are creating a copy of the reference from the original object. So now, if the value of marks changes in the original object or the copy of it, the change will be reflected in both objects. Which is exactly what you're seeing.

Otherwise, I suppose you could try something like this in your copy constructor:

Student(const Student &ob): marks(*(new int (ob.marks)))
                {
                        cout << "TRACE: in copy con" << endl;
                        roll_no = ob.roll_no;
                        pname = new char[strlen(ob.pname)+1];
                        strcpy(pname, ob.pname);
                }

That code should assign marks to the address of a new int created using ob.marks.
But I'm not sure that would work, I've got a feeling that the new int will still be pointing at the same location as the original reference, leaving you back at square one.

Personally I'd say the easiest way of eliminating the problem would be to store marks as an int.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Well, for starters have a good think about your problem.

Take another look at your desired output and really think about it for a minute.
After the user has entered a number (num) between 1-10, you want the first line to count down from num to 1, so your initial minimum value to count down to is 1, but for each line afterwards the minimum is increased by 1.

To generate each line of output, you're going to need some kind of loop to count down from n to minimum and output each value.

And you want to keep outputting lines until the minimum value is greater than the entered number (num). (the very last line output is equal to the entered number, so as soon as the minimum becomes greater than num, you want to stop!)

So this implies that you'll need a second loop to keep track of the minimum value.

Bearing all of that in mind, you should now be able to code a solution for this, it's really not a difficult problem to solve. It may help you to take a piece of paper and actually draw out a flowchart or write some pseudo-code before coding your solution.

When trying to tackle any programming problem, don't just try to dive in and start coding without properly thinking things through and getting a solid program design first. Programmers of all levels have to practice this, even the most experienced. But …

JasonHippy 739 Practically a Master Poster

One thing in your code struck me almost immediately. In functions.cpp you haven't included functions.h, which is most likely the root cause of your problem!

Cheers for now,
Jas.

[edit] P.s. I think you also need to include stdlib.h for srand, but I could be wrong!

JasonHippy 739 Practically a Master Poster

That's cool, at least we're making headway.
Do you know exactly which line of your code is throwing the error inside vector?
Try running in debug mode. When the error occurs and you get a message box about the error, select whatever option it is to break out of the program and into the offending line of code, that'll bring you out to the code you've highlighted in vector.

Sorry, I should point out, I've had a few ciders this evening, so I'm not fully compus mentis ATM. so apologies if I'm not entirely coherent in this post!

Anyway next, take a look at the call-stack and it should show you exactly which line of your code was responsible for causing the error to be thrown by the code in vector.

That should make it a lot easier to diagnose the problem.
If it doesn't become immediately apparent to you, then by all means post the details of the offending line of code and we can take a look!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Hello. Can someone tell me what will happen if i have an array Ar[5][5] and a pointer ptr = Ar[0][0] and try accessing the second line of Ar throught ptr by increasing it by 5? I mean ptr+5 ==Ar[1][5] or something else?

You're almost there. Assuming you had a 5X5 array and your pointer was initially at 0,0. If you increment the pointer by 5 you'll end up at array position 1,0.
Not sure about the code you've got in your post though, if that's pseudo-code, then you're more or less on the ball, but just in case lets try to implement a simple example.
Something like this:
Note: for the sake of brevity I've only used a 2X5 array instead of 5X5.

#include <iostream>
using namespace std;

int main()
{
    int array[2][5]={
        {1,2,3,4,5},
        {6,7,8,9,10},
        };

    int *ptr = &array[0][0];
    cout << "The value at the start of the array is: " << *ptr << endl;
    ptr+=5;
    cout << "The value 5 positions from the start of the array is: " << *ptr << endl;
    return 0;
}

so the first cout should output the value 1 and the second should output 6.

Note: This was just a quick example to show you how pointers work, but it's not a particularly exhaustive or practical example.
Also, when using pointers with arrays in this manner, ensure you do not overstep the boundaries of the array, otherwise you could end up knee deep in the doo …

JasonHippy 739 Practically a Master Poster

No probs, glad to have helped!

JasonHippy 739 Practically a Master Poster

My question is, how does it work?

if (high_num < random_num)
        high_num = random_num;
        
        if (low_num > random_num)
        low_num = random_num;

You did write the code yourself didn't you??

Take a closer look at the code, read it aloud if it helps..
if high num is less than random num (therefore random num is greater than high num):
set high num to the value of random num

if low num is greater than random num (therefore random num is lower than low num):
set low num to be equal to the value of random num

Does that clarify things?

[edit: see below:]
BTW, This is another more intuitive way of doing exactly the same thing:

if (random_num > high_num)
        high_num = random_num;
        
        if (random_num < low_num)
        low_num = random_num;

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

ok, well I could be wrong, but I don't think that entitycontroller.h needs to have globals.h included in it, I see no reference to CGlobals in there, so that can probably be removed. That may help.
If the entitycontroller class uses anything from globals.h in the implementation code (e.g. in entitycontroller.cpp), then it's probably best to include it there instead.

Not sure if that's a part of the problem or whether there's something obvious that we're not seeing, but it may be worth giving that a go!

JasonHippy 739 Practically a Master Poster

hi!

I have created a class with 2 constructors and whenever i try to access it i got the error no match for to call int&

here is the code

class A{
      public:
      A(){};
      A(int i);
      
      int moj_broj;
      };

A::A(int i):moj_broj(i){}

int main()
{
    A something;   
    cout<<"before "<<something.moj_broj<<endl;
    something(5);    
    cout<<"after "<<something.moj_broj<<endl;
}

Try doing this instead:
e.g.

class A{
      public:
      A(){};
      A(int i);
      
      int moj_broj;
      };

A::A(int i):moj_broj(i){}

int main()
{
    A something;   
    cout<<"before "<<something.moj_broj<<endl;
    something = A(5);    
    cout<<"after "<<something.moj_broj<<endl;
}

That should compile and run ok.
Note: in the first cout, you'll see some arbitrary value output because the value of moj_broj is uninitialised by the default constructor.
Cheers for now,
Jas

{edit: Dammit beaten to the punch..}

JasonHippy 739 Practically a Master Poster

Ah, still working on the ol' engine I see!
Looking at the actual error and your code; I think in this instance, forward declaring the entitycontroller class is not working in globals.h. In fact thinking about it logically, forward declaring the class in globals.h isn't really appropriate either. The globals header only contains a struct and I'm guessing that there's no globals.cpp file which includes entitycontroller.h either, so therefore the compiler can't work out exactly what the entitycontroller class is in globals.h
Thus, you need to #include entitycontroller.h in globals.h. I'm pretty certain that will clear things up for you....Lose the forward declaration and just include the header for entitycontroller in globals.h

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

The answer is pretty simple.

1. Input a number as an int (as you're doing)
2. Cast the number to double in your log calculation and store the result of the calculation in a double variable.
e.g.

double calcVal = log((double)num)/log(2.0);

3. Create an int version of the result from the above calculation.
e.g.

int calcVal2 = (int)calcVal;

4. Subtract the int from the double, leaving you with the decimal remainder. (0.00003454865..or whatever)
e.g.

double decimal = calcVal - calcVal2;

5. Multiply the decimal remainder by something like 100000 or so and store the final value as an int. This will truncate the later decimal places, from the remainder thereby avoiding the inherent problems with floating point arithmetic.
e.g.

int final = (int)(decimal*1000000);

6. If the final value is 0, then your number is a power of two.

Cheers for now,
Jas.

jonsca commented: Nice +2
JasonHippy 739 Practically a Master Poster

Good Afternoon All,

I have a template that I'm working on with the same flash header on each page. The header contains the drop down menu to go to the other HTML pages in which the header is placed. I noticed this as one of the parameter lines

<param name="movie" value="../../../client%20websites/Kingdom%20Coaltion%20International/KCIF%20phase%202/MTech/cugb/header_v8.swf?button=2" />

Can someone explain what I have put in green please? With all the Flash I have seen and worked with this is my first for this.

Thanks for your time and assistance.

To put it very simply, the code you've highlighted in green is the name of the .swf and a parameter that is passed into the .swf.

Something in the actionscript inside the .swf will then use the passed-in value to initialise a variable in the script.

There are several ways of passing parameters to a .swf and this is one of them!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

From the looks of the error you're getting, I'd say you probably need to create an override for the operator< to allow two instances of your node class to be compared.

I've not really looked through your code too much, I've only given it a brief once over so I'm not 100% on what you're doing, but I'd guess that you need to be adding something like this:

bool operator<(const Node &n1, const Node &n2)
{
	return n1.path_cost < n2.path_cost;
}

If that's not exactly what you want, you might just want to slap the code from cmpNodes() in there. Either way, you should put your own code in there to compare two Nodes. But one thing's for sure, the compiler is almost certainly complaining about the lack of an operator< override!

I did notice a few other things during my brief sweep of your code. I noticed with your usage of printf, scanf and sscanf, you're mixing some outdated and potentially unsafe C stuff with C++ there. Could be worth updating. It also looks as if the variable 'line_no' is uninitialised at line 124 before it is incremented at line 132. Another potential bug!

You should also be getting an error about the ChildNode function as it doesn't return anything ATM. But I'm guessing that's because you haven't got round to implementing that yet!

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Yeah I kinda like the old interface. It took a long time to get used too.
Do you have any examples of work you've done using blender Jason?

Here are some of mine...

http://blenderartists.org/forum/showthread.php?t=86235
http://blenderartists.org/forum/showthread.php?t=109966
http://blenderartists.org/forum/showthread.php?t=130718
http://blenderartists.org/forum/showthread.php?t=92345

Nice work..Especially with the glasses!

Even after several years, I'm still really learning blender. So most of my stuff has been tutorials and messing about with plugins and things. I also had a go (unsucessfully) at fixing the very buggy VRML2 import/export scripts. I have done a few other random bit's 'n bobs of my own...Most are embarrassingly bad though!

The banner image in the header of my personal website is about the only semi-decent rendering of mine that I can find. I'm quite proud of the skull model in it, I also did a few 3D versions of my previous bands logo, but other than that I've not really done masses.

Blender is something I tinker with on and off. I enjoy messing around with it, but I rarely seem to set out to do anything particularly productive/creative with it!

Most of my blender stuff is on one of my old hard-drives...I'll have to dig it out and take a look to see what I can find! If I can find anything semi-decent I'll post it!

I even bought the 'Blender for Dummies' book a while ago with the intention of working through it, to try to fill …

JasonHippy 739 Practically a Master Poster

thats amazing thankyou would you explain to me what it means when you have said overridden? and the handler?

kitty

OK, I'm not sure whether I'm strictly using the correct terminology here, I'm also not 100% au fait with the tk library, but....
Basically components like the buttons in the tk library use callbacks to deal with events like mouse button clicks (or keypresses or any number of other events defined in the tk library).

A callback is a function which gets called whenever a specified event occurs. Another term commonly used for callback functions used with events is 'event handler'.

So when I use the term 'handler' or 'event handler' I'm talking about the callback function, the function that gets called when the button is clicked. (or when a timer expires, or when some other relevant event occurs to an object!)

From your original code, you set a callback/event handler for your buttons in these 2 lines:

cmd = lambda x=(r,c): self.click(x)      button=tk.Button(self.win,text='',width=5,relief=rel,command=cmd)

You created a button and you told it that the command to execute when the button was pressed was the self.click() function passing the value of x.

That was all well and good for left-clicks, but there was no way of telling the button how to handle right-clicks from the buttons constructor (at least none that I could see). So by default (unless I'm mistaken) you could only set a callback for left mouse clicks, but not right-mouse clicks.

JasonHippy 739 Practically a Master Poster

Try opening up a python command line, and enter the folowing:
help()
modules

After a short while you should see a list of all installed modules.

Does PIL appear anywhere in the list??
If you can't see it, you should try running the PIL installer again.
But if it is there, I'm not sure what to suggest....

Just a thought, which version/s of python do you have installed?
If you've got more than one version of python installed, have you installed PIL for a different version of python?

For example, I've got 5 versions of Python (2.4, 2.5, 2.6, 3.0 and 3.1) installed on my work PC, but I've only got PIL installed for python 2.6.

So as long as I'm using Idle2.6 or the python 2.6 shell, PIL is available to me. But if I'm using any of the other versions of python, it is unavailable to me... Not sure if that could be your problem...

Other than that I'm pretty much out of ideas!
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

OK, using your previous code as a base, I've modified it slightly and come up with something which does more or less exactly what you wanted.

As you'll see I've moved some of your code around and created an extra class (GameSquare) which is used by each square on the board.

When the game is initialised, it uses the arrays you set up (under_vals and disp_vals) to determine which of the squares are bombs and how many bombs are near each square.

As each square knows whether or not it's a bomb, the only things left to deal with are the left and right clicks.
On a left click, if the square has a bomb, it will explode and the game will be over. If it does not, it will go green and display the number of bombs surrounding it.
On a right click, the square goes orange and a '?' is displayed.

To achieve this, I created two member functions in the GameSquare class to act as overrides for the click event (one for the left mouse button and one for the right). The calls to self.button.bind() binds one of the new overridden functions to each mouse button, overriding their default functions. And that's really the main thing to take note of in the code below. Other than that, it's pretty much your old code.

Anyway, here's the code:

import Tkinter as tk
import tkMessageBox
from Tkinter import *
import  sys …
JasonHippy 739 Practically a Master Poster

How about this??
This will cause the game board to be reset/redrawn when the user selects 'yes'.

import Tkinter as tk
import tkMessageBox
from Tkinter import *
import sys

class BoardGame:

    under_vals = [
    '0',  '1',  '1', 
    '0',  '1',  '0', 
    '1',  '0',  '0', 
    '0',  '1',  '1', ]

    disp_vals = [
    '',  '',  '', 
    '',  '',  '', 
    '',  '',  '', 
    '',  '',  '', ]
    
    buttons={} #empty dictionary
    def __init__(self):
        self.win = tk.Tk()
        self.win.title("Minesweeper");

        #initialisation happens here
        self.choices = tk.Menu(self.win)
        self.choices.add_command(label="Start new game", command=self.newGame)
        self.win.config(menu=self.choices)

        return
    def displayBoard(self):
        # create all buttons with a loop
        r = 0
        c = 0
        count = 0
        for b in self.under_vals:
            rel = 'ridge'
            cmd = lambda x=(r,c): self.click(x)
      
            button=tk.Button(self.win,text='',width=5,relief=rel,command=cmd)
            button.grid(row=r,column=c)
            self.buttons[(r,c)]=button
            count += 1
            c += 1
            if c > 2:
                c = 0
                r += 1
    def newGame(self):
        self.displayBoard();
    def enterMainLoop(self):
        self.win.mainloop()
    def click(self, i):
        r,c=i
        bomb=self.under_vals[r*3+c]=='1'  #Evaluates whether there is a bomb or not
        if not bomb:
            self.buttons[i].config(bg="#00FF00", text="OK")#config is used to edit
        else:
            if tkMessageBox.askyesno("error", "BOMB- Try Again?"):
                self.newGame()
            else:
                quit()
            
tc = BoardGame()
tc.displayBoard()
tc.enterMainLoop()

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

I found Daniweb when I was trying to find out about a strange compiler error I was getting, but I managed to find an answer to my problem in an already closed thread. Impressed with what I saw here, I joined up.
This was my first ever post:
http://www.daniweb.com/forums/thread166740.html#post772869

And this was the first thread I started:
http://www.daniweb.com/forums/thread196744.html

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Flash used to be timeline based, but you don't need to use it at all. If you use AS3 you can do things without the timeline.

In fact if you download the Flex3 SDK you don't even need to shell out for the Flash IDE either. You can create .as classes for your flash apps/games using any text editor and then compile your swf's using the SDK's command line tools.

Alternatively, if you really wanted to use an IDE, but didn't want to shell out for Flash, there's Flashdevelop (a free open-source .NET based IDE for Windows), which acts as a frontend for the Flex SDK.

I've been developing in flash like this for the last 3 years. Flashdevelop is an excellent bit of software which I use on all of my Windows PC's.

For flash development on *nix, I usually use gEdit (with an Actionscript syntax highlight plugin I found on the web) and the Flex SDK.

I haven't found any alternative flash/flex IDE's on *nix or mac, so I'm afraid it's text files and command-line all the way there!

But hopefully that situation will change...I've heard that there are attempts to port FlashDevelop over to *nix and mac. I've also heard talk of an AS3/Flex plugin in development for Monodevelop. I've also recently started on my own Flex SDK frontend for *nix, but it's still very rough around the edges and nowhere near ready for release yet!

It's just a simple …

JasonHippy 739 Practically a Master Poster

Hmm, looks like there are only two Blender users here on Daniweb then!

After spending another weekend with 2.5 I have to say that it's growing on me. It's still annoying having to search for things in the new UI, but it turns out it's not so bad after all, things are beginning to make sense.

But I've found another niggle...I'm really not sure about the new toolbox menu.(The popup you get when you press space)

The old one had lots of grouped shortcuts to bits of common functionality (stuff you'd use really often when modelling/animating), so you'd just press space and then select the item you wanted from the popup menu.

The new version gives you a little panel which contains a massive linear list of every single bit of functionality in the program. There's also a little edit box which allows you to filter the list according to a keyword. So to see the shortcut link to the 'add cube' functionality you have to type 'add' (which lists all add operations, e.g. add camera, add particle system etc etc) or 'cube' (or 'add cube') which displays only 'add cube'.

The new toolbox popup has proved to be handy for locating bits of functionality that are still hidden somewhere in the unexplored/unfamiliar areas of the new UI, but at the same time it makes the process of quickly doing those common things that bit more awkward in that you'd have to type a keyword …

JasonHippy 739 Practically a Master Poster

I've got the most recent Clutch album (Strange Cousins From The West) on almost constant rotation ATM....Clutch are ace!
Although, I've been listening to 'Watershed' by Opeth and Cynic's 'Traced In Air' loads recently too!

JasonHippy 739 Practically a Master Poster

In this particular case, VS 2008 is the one that is more 'relaxed'. One good place to figure out whether a given piece of code really is standards-compliant, is Comeau's online service. You can check it out at Test Drive Comeau C++ Online.

Yeah, that's true, the MS compilers have never adhered strictly to the standard. As far as I understand it, VS2008 is standards compliant, but I think you have to alter the settings somewhere to make it stick more strictly to the standard. Otherwise by default it is a little looser and will allow things that perhaps other compilers like gcc will reject.. I hadn't taken that into consideration. If the OP is using a more strict compiler, then that could also explain the problems he was having.

{EDIT:} Actually, after messing with VS2008's compiler options, I can't actually get the compiler to throw a warning or an error about the lack of const in the comparison function....So maybe I was wrong, it's just not standards compliant after all!

Jas.

JasonHippy 739 Practically a Master Poster

I'm beginning to suspect that perhaps the OP is using an older compiler which doesn't support the standard library particularly well.

JasonHippy 739 Practically a Master Poster

I concur, that last bit of code you posted works fine in VS2008.

But I'll take a look at it with Code::Blocks tonight on my linux box to see whether that works too.

Which compiler/IDE are you using?

JasonHippy 739 Practically a Master Poster

I think i've have enough of this nonsense of trying to use sort() and crack my head and all... i'm just going with the bubble sort. thanks alot for all your help people :D

Don't give up now!!
Take a look at this thread:
http://www.daniweb.com/forums/thread242984.html#post1064721

It should explain all you need to know about using std::sort with a vector.

Cheers for now.
Jas.

JasonHippy 739 Practically a Master Poster

I've recently been upgraded at work from VS2003 to VS2008 (woo hoo I can finally see inside STL Containers without having to use my own logging class!! :) ).

Visual Studio is a great IDE, the debugging features are second to none, VS2008 is definitely my favourite IDE on Windows.

But I mainly use my *nix laptop for developing at home, so Code::Blocks with gcc/g++ is the order of the day there. Debugging with C::B and gdb can be difficult, but it's worth the effort IMHO.
C::B is really fast to start up and has loads of different built-in project templates, so just like visual studio, you can get a new project up and running pretty quickly.
The wxSmith plugin for C::B is a godsend, allowing RAD with wxWidgets. C::B is very similar to VS in many ways, but perhaps not quite as powerful or as richly featured....But hey, it's free!
It's also cross-platform, so it works equally well on windows and mac too!

I have also tried Anjuta, Netbeans and Eclipse on *nix. I found that Netbeans and Eclipse were just too damn slow to start up (or to do anything with) and I never really got on with Anjuta... I just didn't like it.

Occasionally I'll use Emacs to edit and compile simple single-file programs (like when helping people with code here on Daniweb).
Or use gEdit and compile with the command line....Sometimes you've just gotta do it via the …

JasonHippy 739 Practically a Master Poster

Hmmm, I took a quick look at 2.5 over the weekend (not spent too much time with it yet) and I have to admit I am almost completely lost ATM and not entirely impressed so far!

Other than Blender and Wings3D, I've not really used any other 3D modelling software; so I'm not really sure how it compares to other high-end packages (maya, max etc). But I'd only just about mastered where everything was with the older versions of Blender and finally managed to get my head around the workflow. So my main gripe with 2.5 so far is that I have to relearn how to access all of the functionality I require, 'cause the interface is waaaay different. But hopefully taking a look at the new documentation and having a bit of a play will resolve that issue.

Other than that, the only other gripe so far is, much as it looks pretty neat the way it animates between views (e.g. when you switch from top view to front view), personally I'd rather just go straight to the required view rather than having to wait for it to animate into position each time. I think that will get really annoying after a while. Hopefully there's an option to turn the animation off when changing views.

Ultimately, I think I need to spend a bit more time with 2.5 before I decide whether I like it or not, but at the moment I'm still very much in …

JasonHippy 739 Practically a Master Poster

>In most, if not all OSes; if a program's main function returns an int, 0
>indicates that program execution ended normally.
>Any other value indicates that the program execution ended
>abnormally. In other words an error occurred.

That's required behavior for a C++ implementation. It has nothing to do with the OS, because the calling code is (rather than the OS itself) a C++ runtime that interprets the return value of main and converts it to something suitably equivalent for the system.

Fair point! I was probably oversimplifying my explanation there. But as ever, you've summed things up far more succinctly and accurately than my own fumbling attempt! Thank you Narue! :)

>Likewise if the main function of a program returns boo
The main function doesn't return bool, and suggesting that it does, or that the integer value returned represents a boolean value, is terribly confusing.

I know that, but surpisingly I've seen a few odd programs (emphasis on the odd) that actually use the bool return type for main...Thankfully I don't think that this unusual practice is particularly widespread or particularly well advised for that matter. Certainly not an option I'd choose, but something I have seen used on my travels. So I thought I'd share just in case!

I've only seen it a handful of times. The one time I came across it professionally, you can be sure that I changed the return type to int! Bool main?? Weird!
I …

JasonHippy 739 Practically a Master Poster

Yes it is possible.

If you've been having trouble trying to do this, I'm assuming you were doing something like this:

pResult = p1 + p2

Which is definitely not what you want to do. The compiler probably wouldn't allow it anyway, but what that code would attempt to do is add the memory addresses of p1 and p2 together and assign pResult to the resultant memory address...which could contain literally anything!

But as I've said you'd more likely just get a compiler error saying that the two pointers cannot be added together like that!

Assuming you have three int pointers correctly assigned to valid int variables; To add the values of two pointers together you'd do this:

*pResult = *p1 + *p2;

Which simply adds the values stored at p1 and p2 together and stores the resultant value at pResult.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

I kind of understand, so for this example, what does return T do if its not in a main function?

Well, lets look at that in terms of my definition of what return does:
return exits the 'current function' and returns to the 'calling function' passing an appropriate value.
In this case, the return is in the Add function, so the 'current function' is the Add function, the 'calling function' is whatever bit of code that called the Add() function and the value being returned is T.

So at the return statement in the the Add function, code execution jumps back to whatever bit of code called the Add function and passes the value of T.


Assuming that your function works (I haven't actually read through the rest of the code, I'm just gonna explain the return thing for now):
If you had a void function called process that called the add function like this:

void process()
{
    // not sure how you're using the add function so apologies if this is wrong.
    // the main thing here is the actual function call..
    const int maxSize=200;
    int result;
    Time myTime[200];

    // This is the main thing we're interested in:
    result = Add(myTime, maxSize);

    return;
}

At the line where the Add function is called, the code is basically saying:
"Call the Add function, passing myTime and maxSize and assign the returned value to the variable result"

So execution jumps from …

JasonHippy 739 Practically a Master Poster

OK, I'll try to explain this as simply and accurately as I can.

First though, a note on functions:
All functions must return something...Anything, even if that something is actually nothing (if a function returns nothing then you use the 'void' return type).

Return doesn't end the program unless the call to return is made in the main function.

A more accurate description of what the return keyword does is this:
The return keyword exits the 'current function' (the function we're returning from), returning back up the call-stack to the 'calling function' (i.e. the code that called the 'current function' we're returning from).

I'll try to explain this in more detail, but first take a look at this very quick code snippet as this will form the basis of my explanation:

#include<iostream>

// here's the declaration of a function which returns a boolean (true or false) value
bool somefunction();

// Here's the main function, the entry point of the program
// returns an int value
int main()
{
    if(somefunction())
        return (0); // end the program normally
    else 
        return(1); // end the program but flag an error condition
}

// Here's the definition of someFunction
bool someFunction()
{
    // we'll just return true here
    return true;
}

Now imagine this:
From your OS, you compile and run the above program.

The main() function is the entry point of the program, so when you run your program, your OS loads the program into …

JasonHippy 739 Practically a Master Poster

Listening to new riffs from the two guitarists in my band.....Now I've got to come up with some drum ideas and program/demo them with Cubase at lunchtime....Meh! :yawn: As if I don't have enough to do!

JasonHippy 739 Practically a Master Poster

Have you tried using ios:: flags on the file open instead of the fstream:: flags?
Perhaps try:

fstream file ("myFile.dat", ios::out | ios::binary | ios::app);

Does that make any difference??
Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

No thanks! milk please, but no sugar!

Ever stopped to think and forgot to start again?

JasonHippy 739 Practically a Master Poster

Well you're very nearly there!
You said you wanted to find out how many items in the array were greater than 100, that would imply that you need some kind of counter, which is the missing ingredient in your original description.
So in your code:
You set your counter to 0
You use a for loop to loop through your array.
On each iteration of the loop, if the current item is greater than 100, increment the counter by one.

Once you're out of the loop, your counter holds the number of items which were greater than 100.

Cheers for now,
Jas.

EDIT: doh beaten to the punch!

JasonHippy 739 Practically a Master Poster

Wow, this thread went kinda crazy for a simple little thing didn't it!
Heh heh!

Actually this might give you a more 'expected' result:

cout << "Hello World \n";

/n is not the same as \n :)

Oops, I didn't spot that! I cut 'n pasted the OPs code and made some very minor adjustments..Very shoddy of me! :$

I've tried what you said Jason and i get:

fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

and when i do include that library i get the first error again

Um.. Yes, sorry, when I edited your code in my post I assumed that the inclusion of stdafx was one of your failed attempts at getting your hello to work, I didn't realise that you were actually using precompiled headers in your program (for something as simple as a hello world it seems a bit overkill!). So yes, in that case if your program is set up to use precompiled headers then stdafx should be included!

However, as niek_e said:

Also when creating a console-app in VS be sure to UNcheck "use precompiled headers"

And Jonsca, regarding the std namespace thing...Yes I used 'using namespace std'. It's certainly not going to cause a problem with a one line "hello world" program. But you are right, I could have put a 'using std::cout' instead or explicitly specified std::cout in main itself, both are acceptable alternatives …

JasonHippy 739 Practically a Master Poster

Try this:

#include <iostream>
using namespace std;

int main()
{
	cout << "Hello World /n";
	return 0;
}
JasonHippy 739 Practically a Master Poster

Currently drinking copious amounts of my own blood! blech! :icon_eek:
Don't worry, it's not some wierd satanic thing :icon_evil: and it's not one of those emo-style :icon_sad: self-mutilation moments either....No it's much more mundane than that. I went to the dentist and had a tooth removed yesterday! :scared: :S

Unfortunately, I just sneezed; causing the scab to pop off and well.. Lets just say it's not particularly pleasant! ;)

However, once I've got things under control, I've got a nice cornish pasty and some carrot and coriander soup to contend with for lunch! Plus chocolate fridge cake for pud...Yum!

JasonHippy 739 Practically a Master Poster

OK, I'm not sure if this is something I've dreamt up during some wierd geeky dream (or nightmare!) or whether I've actually seen something about this subject before.

If I have seen this somewhere, for the life of me I can't remember where it was!

Anyway, I believe that you can provide the intermediate object code (the .o or .obj files generated during compilation) and then get your users to link the object code with whatever library/libraries you're using.

So alongside the intermediate object code, you'll need to provide some sort of makefile to make the process easier for your users (possibly also some of the resources..But, not sure on that). They'll need to invoke the compiler to perform only the final link stage to link the object code with the libraries and produce the final executable.

Offhand I'm not sure which compiler switches you'll need to use to achieve this. The best bet there is to refer to the manual for your compiler as those settings will probably be compiler specific.

Sorry I can't be of any more help than that! I've never tried this myself, I'm just passing on what I remembered seeing somewhere..
Or at least what I THINK I saw somewhere!:-/

Hmm, maybe I should give it a go myself and see what happens! {contemplating.....}:?:
Cheers for now,
Jas.

p.s. If this turns out to be pure fiction, I apologise for that too! (Damn me and …

JasonHippy 739 Practically a Master Poster

You can't pass the filename like that, that's just passing "args[1]" as a string literal you need to do something like this:

// build the string..
std::string command = "fc " + (std::string)args[1] + " ../o.txt";

// now execute the command..
code = system(command.c_str());

Now you're good to go!
Cheers for now,
Jas.

EDIT: Dammit, I knew I shouldn't have gone out to put the kettle on before hitting submit!

JasonHippy 739 Practically a Master Poster

Have you tried running your code through a debugger?

If you take the call to fabs out of your return statement in your operator== overload and store the result in a variable and then step through your code and take a look at the value, you'll see the problem.

Change your operator== overload to look like this:

bool operator==(const real& x1, const double x2)
{
	double x3  = fabs(x2 - x1.value);
	return x3 <= x1.error;
}

Step through the code and take a look at the values of x3 and x1.error.

Floating point mathematics strikes again!
This is down to the way that floating point values are handled in computer systems. In any computer system there are a finite number of numbers that can be accurately represented (depending on the architecture). Int values are quite straightforward and can be represented accurately, but floating point values are a bit trickier and are never exact, they are mere approximations. So not every possible decimal number can be accurately represented!

So although you've put 1.1 and 0.1 into your real class, these values are represented as something like 1.10000000000000001 and 0.100000000000000001.

fabs is giving you a result of 0.10000000000000009

Which isn't what you want when you're trying to compare one floating point number against another!

However, if you know how many decimal places you need to be accurate to (e.g. 4!), you could do something like this to compare the values:

bool operator==(const …
JasonHippy 739 Practically a Master Poster

Well think about it!

Take another look at Narue's example and apply that to your problem...

Narue's example uses ints rather than your 'sample' class, but most of the code reflects what you originally posted.
All she's got in addition is a compare function, a call to std::sort and a bit of code to display the sorted array.

Because Narue's comparing pointers to ints, her comparison function uses int pointers. You want to compare two pointers to 'sample' objects.

You want to sort them by 'adress' (address? or a dress?? heh heh!), which is a std::string.
The 'sample' objects are stored as pointers, so to access the 'adress' property which is private you need to call get_adress() via arrow notation (e.g. ptr->get_adress() )

I don't think I can give you any more help without spoonfeeding you the answer and probably getting told off by Narue in the process!
Which I really don't want! heh heh! ;)

Trust me, the answer is staring right in your face!
Cheers for now,
Jas.

EDIT: However if you are still really, really desperately stuck, take a look at this thread:
http://www.daniweb.com/forums/thread242984.html
Should clear things up for you somewhat!

JasonHippy 739 Practically a Master Poster

Take a look at my response to this thread:
http://www.daniweb.com/forums/thread242984.html

That should give you all the information you need.

Cheers for now,
Jas.

JasonHippy 739 Practically a Master Poster

Well, for starters, it's not an ugly solution at all!
It's common sense and good practice! When constructing an object all members should correctly initialised. If you don't know what the value of a member variable is going to be when the class is instantiated, give it a default value. That way it is at least initialised!! Imagine if one of your uninitialised members was a pointer, what would happen if another part of your program attempted to use that uninitialised pointer? C R A S H !!

OK, so you give default values and you add some public functions to allow those members to be updated as and when the correct values are known.

Here, take a look at this slightly expanded example which implements what I've discussed above:

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

class mytype
{
private:
	double x;

public:
	// provide a default initial value for x
	// in the default constructor
	mytype(): x(0.0){};
	mytype(double x1): x(x1){};

	double getx()const{return x;}
	void setx(double val){x=val;}
};

class myclass
{
private:
	mytype y;
public:
	myclass(){};
	myclass(double z): y(z){};

	// getter and setter to get/set myclass.y's x variable.
	double getYsX()const{return y.getx();}
	void setYsX(double val){y.setx(val);}
};

int main()
{
	// call the default constructor
	myclass mine;
	cout << "value in mine.y.x is:" << mine.getYsX() << endl;

	// now let's imagine that we've calculated a value and we want to store it in
	// x in the y of myclass instance mine
	double value = 987.3453;
	mine.setYsX(value);

	cout << …