1. Post #1
    zerf's Avatar
    June 2014
    1,217 Posts
    Ask any programming questions here that don't need their own thread.

    Previous threads:
    Version 1
    Version 2
    Version 3
    Version 4
    Version 5
    Version 6
    Version 7
    Reply With Quote Edit / Delete Reply Windows 10 Firefox United States Show Events Useful Useful x 1Friendly Friendly x 1 (list)

  2. Post #2
    Gold Member
    Octopod's Avatar
    May 2008
    1,514 Posts
    What would be a good name for a class that represents the state of something at a specific point in time?

    Edited:

    leaning towards "snapshot"
    Reply With Quote Edit / Delete Reply Windows 10 Chrome United States Show Events Agree Agree x 6 (list)

  3. Post #3
    Gold Member
    cartman300's Avatar
    April 2011
    3,203 Posts
    What would be a good name for a class that represents the state of something at a specific point in time?

    Edited:

    leaning towards "snapshot"
    Quake 3 also calls states in time "snapshots"

    http://fabiensanglard.net/quake3/network.php
    Reply With Quote Edit / Delete Reply Windows 10 Firefox Croatia Show Events Useful Useful x 1 (list)

  4. Post #4
    Gold Member
    GentlemanLexi's Avatar
    July 2012
    3,894 Posts
    Need help with a good source for learning C#, since Unity uses it and I'd like to create a game in it.

    I'm not financially able to buy any actual source like a book so anything goes really.

  5. Post #5
    Gold Member
    Tamschi's Avatar
    December 2009
    8,675 Posts
    Need help with a good source for learning C#, since Unity uses it and I'd like to create a game in it.

    I'm not financially able to buy any actual source like a book so anything goes really.
    Can you afford them if they're free? Edited: These (C# ones) don't seem that great and are mostly really outdated-ish. I'll try to find something better.
    I can't vouch for any of these because the free book I learned C# with is in German, but I still recommend a good entry-level books over e.g. video tutorials.

    Edited:

    Unity also provides beginner resources, but you may want to consider doing some 'boring' programs first unless you're already proficient in a different language.
    It's likely somewhat more difficult to get the fundamentals down in a relatively high-level environment like Unity's, especially since that one has some quirks that would elsewhere be considered bad practice.

    Edited:

    Here's Microsoft's current starting point for C#, as far as I can tell.
    They recently redid their website and I'm not familiar with the new version.

    How much programming experience do you have? It's hard to properly recommend something without knowing that.

  6. Post #6
    Gold Member
    GentlemanLexi's Avatar
    July 2012
    3,894 Posts
    Can you afford them if they're free? Edited: These (C# ones) don't seem that great and are mostly really outdated-ish. I'll try to find something better.
    I can't vouch for any of these because the free book I learned C# with is in German, but I still recommend a good entry-level books over e.g. video tutorials.

    Edited:

    Unity also provides beginner resources, but you may want to consider doing some 'boring' programs first unless you're already proficient in a different language.
    It's likely somewhat more difficult to get the fundamentals down in a relatively high-level environment like Unity's, especially since that one has some quirks that would elsewhere be considered bad practice.

    Edited:

    Here's Microsoft's current starting point for C#, as far as I can tell.
    They recently redid their website and I'm not familiar with the new version.

    How much programming experience do you have? It's hard to properly recommend something without knowing that.
    I've completed some CodeAcademy courses on HTML and CSS, that's about it.
    Reply With Quote Edit / Delete Reply Windows 10 Chrome United Kingdom Show Events Optimistic Optimistic x 1 (list)

  7. Post #7
    Gold Member
    Tamschi's Avatar
    December 2009
    8,675 Posts
    I've completed some CodeAcademy courses on HTML and CSS, that's about it.
    That's not (necessarily) programming
    HTML + CSS is technically turing-complete because it can model cellular automata though (with the user repeatedly hitting the space bar), but outside of that they aren't considered programming languages.

    Edited:

    Definitely get Visual Studio.
    The Community version is free for commercial use unless you're more than five people using it and it works with Unity. (Well, at least the 2015 version does. The new one should work too, but I didn't test it.)

    Most tutorials/other resources will assume you're using this. That aside, it's afaik just plain the best currently available tool for C# development.
    Reply With Quote Edit / Delete Reply Windows 10 Firefox Germany Show Events Agree Agree x 2 (list)

  8. Post #8
    Gold Member
    paindoc's Avatar
    March 2009
    9,396 Posts
    Visual Studio Code is also good to have installed alongside the full VS IDE, since its really nice to use for looking through source code alongside programming in VS - that way you can avoid having to load up another expensive instance of your IDE just to look through sample code. If C# feels too tough, maybe give python a try? There's no support for Python in VS2017 (yet, but its coming), so VS Code will handle that admirably for you. Python is what I started my more formal learning of programming concepts with, before moving to C++, and I found it great for the initial stages of learning. C# is solid though, and seems like an ideal middle-ground between the abstraction of Python and the depth of C++. I just know that starting programming is daunting, and when I started last summer my most recent experience was HTML/CSS and all my C firmware work was so long ago that it was practically forgotten entirely.

    What's the safest way to handle move semantics for a complex derived class whose primary data member is a vector of pointers to complex objects (no pointers in stored objects, though)? Swap for move makes me nervous - don't you have to ensure you default construct the destination when move constructing, since swapping to a non-default constructed object w/ pointers could cause issues? I've made sure that the class has a valid destructor, but I'm still nervous about things breaking.

    In that vein, whats a good way to run unit tests on this stuff? I'm not sure how to track memory leaks or issues, outside of the difficult to use CRT Debug tools on Windows - and since my unit tests are implemented with Boost unit testing, leaving them cross-platform would be nice.

    To further extend the scope of this question (sorry), what are some good resources on learning to write unit tests? I'm not sure my current unit tests are enough, and I want to integrate more of them. My codebase is getting increasingly large and complex, and its really hard to test things for validity as it stands right now (outside of running the program and waiting for things to break D:) but I don't really know how to design a testing suite/system - all the resources I've found for the Boost framework are about how to use that framework, not about how to setup good tests.

  9. Post #9
    Grammar Nazi General
    Adelle Zhu's Avatar
    April 2009
    2,082 Posts
    I have a dashboard I'm building where I need to get counts of orders with different statuses. If I didn't want to make a new query for each possible status, how can I narrow the counts down using only one query that retrieves all orders?

    I'm using SQLAlchemy btw.

    Code:
    def order_counts(currentuser):
        # gets order counts for status cards on dashboard:
            allorders = session.query(Order).filter(Order.clinic_id == currentuser).all()
    And the cards to display these counts, with placeholder values.


  10. Post #10
    Gold Member
    GentlemanLexi's Avatar
    July 2012
    3,894 Posts
    That's not (necessarily) programming
    HTML + CSS is technically turing-complete because it can model cellular automata though (with the user repeatedly hitting the space bar), but outside of that they aren't considered programming languages.

    Edited:

    Definitely get Visual Studio.
    The Community version is free for commercial use unless you're more than five people using it and it works with Unity. (Well, at least the 2015 version does. The new one should work too, but I didn't test it.)

    Most tutorials/other resources will assume you're using this. That aside, it's afaik just plain the best currently available tool for C# development.
    Visual Studio came with Unity, so I'm just following some beginner tutorials on stuff to see how it works.

  11. Post #11
    Gold Member
    Tamschi's Avatar
    December 2009
    8,675 Posts
    I have a dashboard I'm building where I need to get counts of orders with different statuses. If I didn't want to make a new query for each possible status, how can I narrow the counts down using only one query that retrieves all orders?

    I'm using SQLAlchemy btw.

    Code:
    def order_counts(currentuser):
        # gets order counts for status cards on dashboard:
            allorders = session.query(Order).filter(Order.clinic_id == currentuser).all()
    And the cards to display these counts, with placeholder values.

    Consider using a query that only retrieves the counts instead of any orders.
    According to my database course this really should be a view the DB then provides directly, too, but I hardly work on anything that persists data, so take that with a grain of salt.

    In any case, this snippet here should put you on the right track:
    Code:
    select town, count(town) 
    from user
    group by town

  12. Post #12
    Gold Member
    lum1naire's Avatar
    October 2008
    5,720 Posts
    anybody have any socket programming experience in C/C++ ? It's for an assignment for school, could use some help moving in the right direction.. I've completed the assignment, however my server and client are only working correctly for sending the initial message between them

    It's a simple program, but I can't figure out what might be wrong with it. I think it has something to do with the window being too large, therefore processing more than 1 request at a time and screwing it up, and frankly have found no good resources online to help me figure it out

    Code:
     while (server > 0){        
            
            do {
            
                recv(server, buffer, buffsize, 0);
                string strBuffer(buffer);
                
                if(strBuffer == "Terminate"){
                    isExit = true;
                }
                
                
                for(int i = 0; i < storage.size(); i++){
                    
                    if(storage[i].email == strBuffer){
                        strBuffer = storage[i].publicKey;
                        break;
                    }
            
                }
                
                send(server, strBuffer.c_str(), buffsize, 0);
                
            }while(!isExit);
            
            cout << "Connection has been terminated" << endl;
            close(server);
            exit(1);
            
        }
        
        close(client);
        
        return 0;
    this is the section of my code in the server cpp file that's handling receiving the message, finding if there's a match in the vector and then returning it to the client. It works flawlessly for first request, and then not so much for the others.

  13. Post #13
    Neckbird's Avatar
    April 2011
    453 Posts
    Anyone using intelliJ know what the green highlight means?

    Wasn't there until I used the add static import intention and didn't go away after undoing the intention.

  14. Post #14
    Gold Member
    lum1naire's Avatar
    October 2008
    5,720 Posts
    Nevermind, fixed my earlier issue.. was just a problem with the size of the buffer I was setting. Although I can't say I completely understand what was wrong
    Reply With Quote Edit / Delete Reply Mac Safari United States Show Events Useful Useful x 1 (list)

  15. Post #15
    Gold Member
    WTF Nuke's Avatar
    March 2009
    5,271 Posts
    Probably because of the send, because the size of strBuffer might be smaller than buffersize, meaning you're invoking undefined behavior by going past the end of strBuffer.

  16. Post #16
    faster than stupid, but still slower than everybody else

    June 2010
    3,151 Posts
    Quake 3 also calls states in time "snapshots"

    http://fabiensanglard.net/quake3/network.php
    So does git/GitHub.

  17. Post #17
    Gold Member
    Zombinie's Avatar
    June 2013
    966 Posts
    I need a way to make text change colors (cycle through rainbow) on html for my site

    Or I need someone to tell me what program to use to make a gif of the words "how about no" in comic sans changing colors through the rainbow

    Don't know how to do either

    Found this:



    Except
    -comic sans
    -transparent background
    -maybe wavey?

  18. Post #18
    Gold Member
    PortalGod's Avatar
    August 2009
    2,571 Posts
    http://codepen.io/andyault/pen/bqOXGa

    waves are gonna be impractical to do in html though

  19. Post #19
    Gold Member
    Tamschi's Avatar
    December 2009
    8,675 Posts
    I need a way to make text change colors (cycle through rainbow) on html for my site

    Or I need someone to tell me what program to use to make a gif of the words "how about no" in comic sans changing colors through the rainbow

    Don't know how to do either

    Found this:



    Except
    -comic sans
    -transparent background
    -maybe wavey?
    I'm pretty sure you can do this without scripts as native-ish text:
    - <textPath>
    - <animate> (works for colour attributes too)
    - Comic Sans is available as web font, but I don't know whether it's included in the free plan.

  20. Post #20
    Gold Member
    Zombinie's Avatar
    June 2013
    966 Posts
    I'm pretty sure you can do this without scripts as native-ish text:
    - <textPath>
    - <animate> (works for colour attributes too)
    - Comic Sans is available as web font, but I don't know whether it's included in the free plan.
    http://codepen.io/andyault/pen/bqOXGa

    waves are gonna be impractical to do in html though

    Thank you both so much but I guess this won't work. I am using GoDaddy website builder and they allow custom html, but not css, and I don't know how to change the <animate> to what I need
    Reply With Quote Edit / Delete Reply Windows 7 Internet Explorer 11 United States Show Events Dumb Dumb x 3 (list)

  21. Post #21
    Meow :3
    Ac!dL3ak's Avatar
    July 2005
    6,189 Posts
    Quake 3 also calls states in time "snapshots"

    http://fabiensanglard.net/quake3/network.php
    synonyms are state, frame, and context.

  22. Post #22
    Gold Member
    marvincmarvin's Avatar
    January 2011
    455 Posts
    Can a .NetFramework 4.6.2 library reference a .NetStandard 1.6 library? According to the chart doodle it can, but I'm still getting the "you no can do" error.

  23. Post #23
    Gold Member
    Tamschi's Avatar
    December 2009
    8,675 Posts
    Thank you both so much but I guess this won't work. I am using GoDaddy website builder and they allow custom html, but not css, and I don't know how to change the <animate> to what I need
    Are you sure you can't use CSS inline via <style>?
    In any case, here's a more thorough introduction to SVG animations.
    I suspect you need a keyframe animation of sorts that blends between different colours.

  24. Post #24
    BIG TITLE
    Pat.Lithium's Avatar
    November 2009
    11,590 Posts
    swift question. i'm doing a uni assignment that involves creating a contact list that i can add to and view contacts.

    i understand how to pass data across the view using a segue however i don't understand how i can get the actual instance stored in the cell clicked.

    this is the segue:
    Code:
    if segue.identifier == "showDetail" {
        if let destination = segue.destination as? DetailViewController, let contact = sender as? ContactListEntry {
            destination.contact = contact
        }
    }
    this fails because the sender is a UITableviewCell and not a ContactListEntry. there is a ContactList class which has an array of ContactListEntry called entries.

    so when the cell is clicked and the segue is triggered, the only thing i can get from it is the textlabel, but i need to get the row that was clicked so i can get the entry from the ContactList.

    the DetailViewController.destination is also a ContactListEntry

  25. Post #25
    BIG TITLE
    Pat.Lithium's Avatar
    November 2009
    11,590 Posts
    i figured this one out ^
    Code:
    func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
        rowSelected = indexPath.row
    }
    next problem:
    Code:
    if let destination = segue.destination as? DetailViewController
    doesn't work because i have a navigation controller in between the detail view.

  26. Post #26
    Gold Member
    paindoc's Avatar
    March 2009
    9,396 Posts
    Can anyone point me to a good book or website that can help me figure out working with Qt in C++? The resources I've found are either out of date, intended for learning C++ through Qt, or don't cover the right stuff (like the Qt5 GUI Programming cookbook). I'm trying to tie in the GUI to my application now, and while the application isn't entirely finished yet I need a break from the stuff I'm stuck on and I figure planning my GUI hooks (and implementing them partially) now isn't a bad idea.

  27. Post #27
    Grammar Nazi General
    Adelle Zhu's Avatar
    April 2009
    2,082 Posts
    Struggling with jQuery right now. I'm trying to use autocomplete on a set of fields. Each field needs to call ajax to query MySQL for results. But there needs to be a separate request for each field. The autocomplete script I'm using comes from Material Design for Bootstrap which doesn't seem to have a lot of options for external data. In fact, I think it only accepts a set list of data.

    Can anyone lend me a hand in writing the jQuery for the request?

    This is the autocomplete script from Material Design.

  28. Post #28
    BIG TITLE
    Pat.Lithium's Avatar
    November 2009
    11,590 Posts
    i figured this one out ^
    Code:
    func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
        rowSelected = indexPath.row
    }
    next problem:
    Code:
    if let destination = segue.destination as? DetailViewController
    doesn't work because i have a navigation controller in between the detail view.
    again my bad

    solution
    Code:
    let destination = (segue.destination as! UINavigationController).topViewController as! DetailViewController

  29. Post #29
    Gold Member
    antianan's Avatar
    May 2009
    3,405 Posts
    Can anyone point me to a good book or website that can help me figure out working with Qt in C++? The resources I've found are either out of date, intended for learning C++ through Qt, or don't cover the right stuff (like the Qt5 GUI Programming cookbook). I'm trying to tie in the GUI to my application now, and while the application isn't entirely finished yet I need a break from the stuff I'm stuck on and I figure planning my GUI hooks (and implementing them partially) now isn't a bad idea.
    I don't know man, they have examples on pretty much everything in their wiki, + it might be worth reading a bit of Schlee's book. It covers most of the basic concepts used in the framework, and it also has some excellent examples on how to start with Qt's GUI part.

  30. Post #30
    dnqboy's Avatar
    July 2013
    604 Posts
    Is anyone decent at Java? I have a project due soon that involves arrays and classes and I have been struggling for hours to set up the array (jumbled crossword basically) but I just don't comprehend how they work at all in 2D form. If I could PM someone some code (so I don't get fucked for cheating) and they offer me some tips/direction that would be amazing.

  31. Post #31
    BIG TITLE
    Pat.Lithium's Avatar
    November 2009
    11,590 Posts
    Is anyone decent at Java? I have a project due soon that involves arrays and classes and I have been struggling for hours to set up the array (jumbled crossword basically) but I just don't comprehend how they work at all in 2D form. If I could PM someone some code (so I don't get fucked for cheating) and they offer me some tips/direction that would be amazing.
    i'll be at work for the next 7 or so hours but i'd be glad to help after.

  32. Post #32
    daigennki's Avatar
    December 2014
    1,292 Posts
    My game which I am making using C++ and SDL seems to be getting memory leaks, and I cannot quite figure out what is causing it. Here is what the debug output in VS2015 says:
    Code:
    Detected memory leaks!
    Dumping objects ->
    {143} normal block at 0x00CC94D0, 80 bytes long.
     Data: <ABCDEFGHIJKLMNOP> 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 
    {142} normal block at 0x00CE08B8, 8 bytes long.
     Data: <        > D4 A7 AC 00 00 00 00 00 
    Object dump complete.
    Does that look familiar to anybody? This is nothing urgent since Task Manager does not seem to show the memory usage going out of control and the program does what it is supposed to do, but I do not want little problems like these causing bigger problems later.

  33. Post #33
    BIG TITLE
    Pat.Lithium's Avatar
    November 2009
    11,590 Posts
    My game which I am making using C++ and SDL seems to be getting memory leaks, and I cannot quite figure out what is causing it. Here is what the debug output in VS2015 says:
    Code:
    Detected memory leaks!
    Dumping objects ->
    {143} normal block at 0x00CC94D0, 80 bytes long.
     Data: <ABCDEFGHIJKLMNOP> 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 
    {142} normal block at 0x00CE08B8, 8 bytes long.
     Data: <        > D4 A7 AC 00 00 00 00 00 
    Object dump complete.
    Does that look familiar to anybody? This is nothing urgent since Task Manager does not seem to show the memory usage going out of control and the program does what it is supposed to do, but I do not want little problems like these causing bigger problems later.
    it can be a pain to find memory leaks if you have already coded up a shit load of code, but try this might help you pin point the class/method thats causing the leaks
    https://msdn.microsoft.com/en-us/library/x98tx3cf.aspx

    Edited:

    specifically you want to be able to break when the leaks are detected so try this
    Code:
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
    _CrtSetBreakAlloc(143);
    _CrtSetBreakAlloc(142);

  34. Post #34
    Gold Member
    paindoc's Avatar
    March 2009
    9,396 Posts
    I don't know man, they have examples on pretty much everything in their wiki, + it might be worth reading a bit of Schlee's book. It covers most of the basic concepts used in the framework, and it also has some excellent examples on how to start with Qt's GUI part.
    The main issue I was having was the weird/broken way includes can work if you don't use one of their pre-built project files, but I added the whole Qt include directory to my project's include search path and that fixed things (fucking duh). Now I'm just getting weird errors that I think are bugs in the 5.9 alpha, but Qt 5.8 won't build on MSVC because of constexpr funkiness (welp).

  35. Post #35
    Grammar Nazi General
    Adelle Zhu's Avatar
    April 2009
    2,082 Posts
    I'm trying to do a project for java and when I try to count the rows in a CSV, it runs in a loop forever. If I add a quick print of the values in the CSV, it works fine and ends.


    This spins forever:
    Code:
    //Count rows in CSV so we know how many to declare in arrays later:
            while (file_stream.hasNext()){
                row_count++;
            }
            System.out.print(row_count);
            file_stream.close();
    This does not:
    Code:
    //Count rows in CSV so we know how many to declare in arrays later:
            while (file_stream.hasNext()){
                System.out.print(file_stream.next() + "/" + "\n");
                row_count++;
            }
            System.out.print(row_count);
            file_stream.close();
    I don't know what it's hanging on.

  36. Post #36
    johnnyaka's Avatar
    January 2012
    469 Posts
    I'm trying to do a project for java and when I try to count the rows in a CSV, it runs in a loop forever. If I add a quick print of the values in the CSV, it works fine and ends.


    This spins forever:
    Code:
    //Count rows in CSV so we know how many to declare in arrays later:
            while (file_stream.hasNext()){
                row_count++;
            }
            System.out.print(row_count);
            file_stream.close();
    This does not:
    Code:
    //Count rows in CSV so we know how many to declare in arrays later:
            while (file_stream.hasNext()){
                System.out.print(file_stream.next() + "/" + "\n");
                row_count++;
            }
            System.out.print(row_count);
            file_stream.close();
    I don't know what it's hanging on.
    In the first example, you're not using `file_stream.next()`. Without this call, you will always look at the same row in the CSV --> `hasNext()` will never return false.

    Basically, `file_stream.next()` will give you the current row AND move the internal pointer to the next row.

  37. Post #37
    Gold Member
    cartman300's Avatar
    April 2011
    3,203 Posts
    I'm trying to do a project for java and when I try to count the rows in a CSV, it runs in a loop forever. If I add a quick print of the values in the CSV, it works fine and ends.


    This spins forever:
    Code:
    //Count rows in CSV so we know how many to declare in arrays later:
            while (file_stream.hasNext()){
                row_count++;
            }
            System.out.print(row_count);
            file_stream.close();
    This does not:
    Code:
    //Count rows in CSV so we know how many to declare in arrays later:
            while (file_stream.hasNext()){
                System.out.print(file_stream.next() + "/" + "\n");
                row_count++;
            }
            System.out.print(row_count);
            file_stream.close();
    I don't know what it's hanging on.
    hasNext only returns whether there is a next element or not, it does not return it, effectively resulting in while(true) { }

    next() actually "pops" the element from the stream
    Reply With Quote Edit / Delete Reply Windows 10 Firefox Croatia Show Events Agree Agree x 1 (list)

  38. Post #38
    daigennki's Avatar
    December 2014
    1,292 Posts
    it can be a pain to find memory leaks if you have already coded up a shit load of code, but try this might help you pin point the class/method thats causing the leaks
    https://msdn.microsoft.com/en-us/library/x98tx3cf.aspx

    Edited:

    specifically you want to be able to break when the leaks are detected so try this
    Code:
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
    _CrtSetBreakAlloc(143);
    _CrtSetBreakAlloc(142);
    Weird, nothing changed, and although I defined _CRTDBG_MAP_ALLOC it does not show which line of which file is the cause.

  39. Post #39
    Gold Member
    errur's Avatar
    December 2009
    945 Posts
    How can I turn weaponA = weaponA.Function(); into weaponA.Function();

    Code:
    Transform t = transform.FindChild("Gun");      
    
    weaponA = weaponA.InstantiateWeapon(t);
    weaponB = weaponB.InstantiateWeapon(t);
    weaponC = weaponC.InstantiateWeapon(t);
    Code:
    public Weapon InstantiateWeapon(Transform t)
    {
    	Weapon wep = Instantiate(this);
    	wep.transform.localPosition = t.position;
    	wep.transform.rotation = t.rotation;
    	wep.transform.parent = t;
    
    	return wep;
    }
    If that doesn't work I at least thought of making it a static function so I can just call weaponA = Weapon.InstantiateWeapon(); but if I make it static I can't do Weapon wep = Instantiate(this); (this can't be used but I need to instantiate wep in unity this way).

    Obviously I can't add this = wep; into the Instantiate function, but is there something similar to that?

    Any ideas? C# by the way.

  40. Post #40
    faster than stupid, but still slower than everybody else

    June 2010
    3,151 Posts
    I'm not sure what you are exactly trying to do, but why not use a builder pattern to build and create weapon instances?

    Generally when you instantiate something using this, it is a code smell and there is likely a better way to accomplish what you're trying to do.

    I also don't understand your interface. In each of your examples you pass two different type of objects, a Tranform object type and whatever class contains the InstantiateWeapon method.