User Profile

Collapse

Profile Sidebar

Collapse
ducttape
ducttape
Last Activity: Oct 1 '09, 11:19 AM
Joined: May 8 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DesktopLocation vs Control.MousePosition vs e.Location (where e is MouseEventArgs)

    Hello

    I'm busy working with an MDI parent and child forms. I've found that there is a discrepancy between the locations returned by DesktopLocation , Control.MousePo sition and MouseEventArgs e.Location, but I can't work out why or what exactly the discrepancy is.

    My forms are all custom without title bars and thus I've had to create my own moving methods, etc. This is obviously related to the location of the mouse...
    See more | Go to post

  • ducttape
    replied to Reading complex XML files in C#
    I think xpath is doing more than i need it to, it seems almost SQL-like and I'm worried about computational efficiency.

    I literally just need to read each record, which contains author, title, etc, into a data structure. There must be an easy way to do this? I can do it when "record"s are the root nodes but as you can see from my xml file the actual data is stored several levels deep.

    I would like to do it...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Reading complex XML files in C#
    Thanks very much, I'll check out those tutorials I havent heard of XPathNavigator before.

    I have no idea what i'm doing though so I will probably be back :)
    See more | Go to post

    Leave a comment:


  • ducttape
    started a topic Reading complex XML files in C#

    Reading complex XML files in C#

    Hi, I have been trying for several days to read XML files into my program. I have been following several good tutorials on the internet, but I am struggling because the particular XML files that I am reading have several nested fields:

    <?xml version="1.0" encoding="UTF-8" ?>
    <xml>
    <records>
    <record>
    <database name="test.enl" >test</database>...
    See more | Go to post

  • ducttape
    replied to Forward declaration in C++ not working
    in C
    Thanks for your patience. Everything was declared and I was not using anything. I have guard mechanisms around all of my classes. I forward declared childClass and then added a childClass variable to parentClass. In childClass, I forward declared parentClass and added a parentClass variable to childClass. So far I have not defined anything or tried to use any of its members. If simply adding a variable requires you to define the class then...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    I spoke too soon. I forgot my code example doesn't actually have a child belonging to the parent. If I try to add one, even if I forward declare childClass, I get error C2079: 'parentClass::c ' uses undefined class 'childClass'. This is from simply adding a childClass variable to parentClass, not even from instantiating it.
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    It's working with the forward declaration of childClass instead of the #include childClass. Thanks so much for your patience. In retrospect I'm embarassed that I too expected psychic abilities from the compiler. It just seemed so natural.

    One of the starkest differences is that Java's variables are pointers by default. To create a new instance you actually have to use the "new" keyword. It seems to me to be a much more...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    It's actually quite an interesting discussion, I always did wonder it was bad programming form on my part but I do it all the time in Java and C#: for the class that instantiates another class to pass itself through as a parameter so that the second class can refer to it as its parent. It's a really neat trick which saves bucketloads of code and I'd imagine saves bucketloads of memory. But if C++ doesn't allow it easily perhaps that's indicative...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    I read up about include guards, I found this link helpful: http://www.efnetcpp.org/wiki/Include_guards

    Unfortunately it seems like it's not what I need after all becuase it doesn't solve the original problem that A needs to have B defined and B needs to have A defined.

    This is really messing with my head I feel like I'm going a bit crazy thinking about it. I'm kind of coming to the conclusion that you can't have...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    Ok, that sounds like exactly what I need, I'll read up about the "guard mechanism" - is that what it's called? Perhaps you only need to put that guard around one of the classes to stop the preprocessor from going all the way down. I'll experiment and post my findings here. Thanks again
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    Thanks Jos, what do you mean, protect the preprocessor from going all the way down?

    I added your code, it works if I leave out the #include in one of the classes, but if I put it in (which I obviously need to) it doesn't recognise it.

    I include the code here in case I'm neglecting to tell you something.

    Code:
    //parentClass.h
    #ifndef PARENTCLASS_H
    #define PARENTCLASS_H
    
    #include
    ...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    I think I understand how headers work now. I can see the advantages and I'm going to split all my classes into seperate files from now on. So, I've split up the parent and the child class, made headers for them with their variables, and seperate .cpp files for their methods. The files all now #include each other.

    The problem I'm getting now is error C1014: too many include files : depth = 1024. I figure its because class 1 includes...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    Hi Banfa, I'm getting really close, I can feel it! I actually went and implemented that conceptual code in Visual Studio 2008 and I even got it to compile. So I added a variable to pass through to test it, and drew a blank. By the way, that article convinced me using "this" in the constructor was a bad idea. Here's the code, which results in the same error (..uses undefined class..)

    Code:
    #include "stdafx.h"
    ...
    See more | Go to post

    Leave a comment:


  • ducttape
    replied to Forward declaration in C++ not working
    in C
    OK!! That's really helpful, I was assuming I was passing through a pointer just as in Java. As you may have guessed the code I posted was just a conceptual version, in the actual version the parent (a particle system) contains an array of children (particles) - I just want each child to have a pointer to its parent so it can ask it what it needs to look like when it respawns.

    So, if I do something like this:

    Code:
    class
    ...
    See more | Go to post

    Leave a comment:


  • ducttape
    started a topic Forward declaration in C++ not working
    in C

    Forward declaration in C++ not working

    myProgram.cpp:

    Code:
    class childClass
    {
              parentClass parent;  //reference to class that created this child
              childClass(parentClass p)
              {
                        parent = p;
              }
    };
    
    class parentClass
    {
              childClass child(this);
    };


    This would work fine in Java, which I'm more accustomed to,...
    See more | Go to post
No activity results to display
Show More
Working...