• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=FalconKrunch;46142642]If we're talking C++ then you don't have to, I don't know if there's other languages that support nameless structs/unions.[/QUOTE] How do you access a nameless structure in C++?
You should be able to access the members directly. AFAIK, you use the struct in a union to let the compiler know that they're one "object". Someone correct me if I'm wrong on this. Let's say you have this structure. [CODE] class foo { union { struct { float 1, 2; }; double 3; } } [/CODE] you should be able to access all members by doing just doing foo.1, foo.2, or foo.3.
[QUOTE=FalconKrunch;46142642]If we're talking C++ then you don't have to, I don't know if there's other languages that support nameless structs/unions.[/QUOTE] Anonymous structs are not part of the C++ standard, anonymous unions are.
[QUOTE=farmatyr;46142992]Anonymous structs are not part of the C++ standard, anonymous unions are.[/QUOTE] Ah, I see. I've been using Visual Studio since forever so I didn't know that.
[QUOTE=farmatyr;46142992]Anonymous structs are not part of the C++ standard, anonymous unions are.[/QUOTE] I thought so about structs. otherwise there'd be no point in making it a struct, right? are there anonymous Unions in C?
[QUOTE=proboardslol;46143235]I thought so about structs. otherwise there'd be no point in making it a struct, right? are there anonymous Unions in C?[/QUOTE] They are really neat for unions, but not necessary. I wouldn't be surprised if they make it into C++17.
[QUOTE=Number-41;46135844]More of a soft question: should I bother learning Java if I would ever want to code professionally (more in a scientific/engineering environment)? I know some C++, C, Matlab, Python and Fortran (and they're nice languages imho, although I don't like Matlab and Fortran that much) but Java seems like such a bitch, but it dominates every single goddamn course at my university. What do? On a side note, would you prefer knowing a single versatile language really well or rather be okay'ish at several languages? How long do you have to spend to know a language to a decent level? It seems to me that once you have some programming experience, getting started and doing actual useful stuff in any language doesn't take that long. Can you just show up at a company with notions of language X but tell them that you can get up to speed in a couple months? Of course you have to nuance this, knowing some C and then saying that you're able to do heavy OOP in C++ in a couple of months is stretching it... Also, how do you learn collaboration/big projects? Do they train this in CS courses? I can't fathom how you can work on a thing with 100s of other programmers on a project with thousands of lines of code. I'm asking this because although I study physics, I like programming a lot and making a living with it seems like a viable choice. But I don't know how IT companies see physicists, it's a different degree after all...[/QUOTE] With a physics degree you should easily be able to work at IT stuff, you'd just get paid more :v: Seriously though, Java is easy to pick up if you know a different language occupying the same area like C#. Probably especially C# since it's almost like Java but not "such a bitch" to actually do anything in. I'd say learning many languages at least to a level where you can do basic things without Internet connection is a good idea, since they emphasize different paradigms and you can transfer that to your preferred language fairly easily. That doesn't preclude knowing one or two of them really well, since the more languages you know the faster you can pick up additional ones (except for the standard library, that needs a week of experience or two). There are very few languages that are actually versatile enough to be used for many different things. C# is okay or good for many applications, but there are a few specific things that are more cumbersome. F# is [I]really[/I] nice when processing data, but when doing mutable OOP it's very verbose. Haskell runs insanely fast but it has bad interop with other languages and to my knowledge not exactly good at things that actually are primarily imperative problems. Java is equally extremely annoying at pretty much everything though, [I]except[/I] for the fact that it has covariant return types on function overloads. I really don't get why it's so commonly used, since it's so terrible to work with. Don't dare to put an umlaut into a comment or you'll break the build on the server that has a different default encoding etc. Better than getting C++ to compile at all though, I suppose. If I'm not mistaken Java is more for enterprise jobs managing some weird tracking software and things like that. You won't find it in places where the program primarily has to run fast, so [I]I think[/I] large parts of the scientific environment are out. If you want to take a CS course then sure, it would be a good idea to know it, but the courses for students of other disciplines shouldn't require actually being able to program. (The one I took definitely didn't, Java was a tiny part and I could have done that without ever touching the documentation.) If you know C++ well and and move to Java... three weeks maybe. Less if you actually practise. If you come from a language that's a superset of it like C# or *shudder* VB.NET, you can just read a book about it in 1-2 weeks and will be able to do it on a level where you can get a job with it. (I did that for a work placement in school, I think they ascribed me good existing skills or something like that :v:) About working on large projects: With version control that actually really easy. They'll teach you on the job, but if it's centralised and you have to lock files for everyone before being able to work on them then [B][I]run[/I][/B]. (I had to put up with that and the system costs a few 100€ per user apparently, complete with nasty bugs etc. Mercurial is 1000% nicer and most importantly [U]free[/U].) You could also just start a thread asking for people's version control schemes, but that's like spaces vs tabs, only more serious. I really like the .NET approach, since within that framework interop is near-perfect so you can just write each part of the application in whatever language is the best fit for that particular problem. There are other frameworks that can do that but I haven't gotten any of them to work.
Cross-platform .NET isn't fun either. Sure, there's Mono, but it's far from perfect, whereas with Java, you don't even have to worry about it. It's pretty much the only modern, popular system that allows you to do rapid GUI development without manual memory management and all that stuff. [quote]If you want to take a CS course then sure, it would be a good idea to know it, but the courses for students of other disciplines shouldn't require actually being able to program. (The one I took definitely didn't, Java was a tiny part and I could have done that without ever touching the documentation.)[/quote] This is very variable from university to university. Mine has several Java courses in its CS curriculum. [quote]If I'm not mistaken Java is more for enterprise jobs managing some weird tracking software and things like that. You won't find it in places where the program primarily has to run fast, so I think large parts of the scientific environment are out.[/quote] You'll find it at universities even in research projects (though generally not doing any heavy computations by itself) because of the undergrads raised on it. [quote]They'll teach you on the job, but if it's centralised [...] then [B][I]run[/I][/B].[/quote] Good luck with that. Plenty of places that run TFS etc. [editline]3rd October 2014[/editline] Somewhat off-topic, but: [quote]If I'm not mistaken Java is more for enterprise jobs managing some weird tracking software and things like that. [/quote] At least it's not SAP.
Is it possible to do a netsend with C++ on a Windows 7 computer, or something equivalent? I know that msg is in certain versions of Windows 7 but I'm wondering how difficult it would be to write an alternative that would send a message to computers on the same network.
[QUOTE=DrTaxi;46144238][...] Good luck with that. Plenty of places that run TFS etc.[/QUOTE] This was some German-built abomination written in Java on Linux and very obviously not tested for Windows. I suppose if it's one of the larger ones there will be an Hg plugin to at least have a sane system locally. [QUOTE]Somewhat off-topic, but: At least it's not SAP.[/QUOTE] You'll laugh: The work-hour tracking software by SAP was actually the only thing used at that place that worked without a single hitch. It was also a good fifty times faster than all the other stuff, but I'm not sure why. Probably because it has some weird proprietary and super lean GUI system (that is extremely ugly but w/e, it works). It seems that a lot of their programs are actually written in their own programming language and other strange things. Probably comes with maintaining software created in the 90s. [editline]4th October 2014[/editline] [QUOTE=Duskling;46144679]Is it possible to do a netsend with C++ on a Windows 7 computer, or something equivalent? I know that msg is in certain versions of Windows 7 but I'm wondering how difficult it would be to write an alternative that would send a message to computers on the same network.[/QUOTE] I was fairly certain that netsend just does an UDP broadcast, according to Wikipedia it uses TCP too though. [URL="http://en.wikipedia.org/wiki/Windows_Messenger_service"]It seems to work using NetBIOS and MailSlot[/URL], so you should be able to either hook into or emulate those services.
I was fairly certain that netsend just does an UDP broadcast, according to Wikipedia it uses TCP too though. [URL="http://en.wikipedia.org/wiki/Windows_Messenger_service"]It seems to work using NetBIOS and MailSlot[/URL], so you should be able to either hook into or emulate those services.[/QUOTE] Interesting. I'll check it out.
I posted this in the Unity thread, but I guess it belongs here too. I've hit a bit of an issue with my collisions, and after a few hours of problem solving I still can't figure out what's up. I've got a character set up, with seperate collision boxes/spheres for head, body and feet collisions (ceiling, walls, ground). [IMG]http://i.gyazo.com/88a86c1b0b50e1dc8daba89d831498a5.png[/IMG] I've got a semi-grid based world, where I'm using a prefab square with an attached 2D box collider that I'm manually duplicating. The character's ground collisions are essentially: [code]void CollideFeet() { if ((feetColliderL.colliding) | (feetColliderR.colliding)) { touchGround = true; } else if ((feetColliderL.colliding == false) & (feetColliderR.colliding == false)) { touchGround = false; print ("off--------------ground"); } }[/code] The issue I'm getting is that as my character moves from square to square, both feet report that they're not colliding with the world at the same time. Once inertia takes them a little ways further, they collide again. I thought that having two seperate feet colliders would solve this, as I assumed it was an issue with entering square 2 before leaving square 1, resulting in square 2 setting player's collision to true then square 1 setting it to false a moment later, but this doesn't seem to be the case when both feet are giving me a non-collision report at the same time. Any ideas?
Does anyone here have any experience with microsoft fakes? I'm trying to detour a function of another program, but all the tutorials are for system libs or applications you have the source code for. Here is my code: [t]http://a.pomf.se/wcohmm.png[/t]
Does anyone have any small projects that I can work on in Java that are simple to do, but just good programming practice and experience?
[QUOTE=NixNax123;46148701]Does anyone have any small projects that I can work on in Java that are simple to do, but just good programming practice and experience?[/QUOTE] You could make a program to convert a .jpg to a .png or something along those lines. Or import a .png and change it to black and white. It seems complicated, but once you have the file input correct, you just have to learn the specifications of the file format and create your own parser/lexer. Should be relatively simple and fun with the proper documentation.
Anyone know of a way to use regex to select whole words? For example, even including the quotes. "This is some text." "Yolo, swag, and bae." The words I want to select, "[B][U]This[/U] [U]is[/U] [U]some[/U] [U]text[/U][/B]." "[U][B]Yolo[/B][/U], [U][B]swag[/B][/U], [U][B]and[/B][/U] [U][B]bae[/B][/U]." I am still in my infancy with my ruby knowledge as well as regex. So I'm trying to expand on it.
[QUOTE=Duskling;46148857]You could make a program to convert a .jpg to a .png or something along those lines. Or import a .png and change it to black and white. It seems complicated, but once you have the file input correct, you just have to learn the specifications of the file format and create your own parser/lexer. Should be relatively simple and fun with the proper documentation.[/QUOTE]Oooh! Good idea! I'll try that, and I'll learn stuff too! I love learning stuff like that, that's actually useful. [editline]4th October 2014[/editline] [QUOTE=blacksam;46149107]Anyone know of a way to use regex to select whole words? For example, even including the quotes. "This is some text." "Yolo, swag, and bae." The words I want to select, "[B][U]This[/U] [U]is[/U] [U]some[/U] [U]text[/U][/B]." "[U][B]Yolo[/B][/U], [U][B]swag[/B][/U], [U][B]and[/B][/U] [U][B]bae[/B][/U]." I am still in my infancy with my ruby knowledge as well as regex. So I'm trying to expand on it.[/QUOTE] [code]\s*("[^"]+"|[^ ,]+)[/code] that would include stuff enclosed in quotes too [editline]4th October 2014[/editline] of course if you don't need any of that you could just use [code]\S+[/code] [editline]4th October 2014[/editline] i could be terribly wrong though
[QUOTE=NixNax123;46148701]Does anyone have any small projects that I can work on in Java that are simple to do, but just good programming practice and experience?[/QUOTE] Make a program that converts a number of one base (say, base 10), and converts it to another base (say, hexadecimal). No using Logarithms
[QUOTE=proboardslol;46149674]Make a program that converts a number of one base (say, base 10), and converts it to another base (say, hexadecimal). No using Logarithms[/QUOTE] Okay!
[QUOTE=NixNax123;46149173]Oooh! Good idea! I'll try that, and I'll learn stuff too! I love learning stuff like that, that's actually useful. [editline]4th October 2014[/editline] [code]\s*("[^"]+"|[^ ,]+)[/code] that would include stuff enclosed in quotes too [editline]4th October 2014[/editline] of course if you don't need any of that you could just use [code]\S+[/code] [editline]4th October 2014[/editline] i could be terribly wrong though[/QUOTE] It's all good in the hood. I was fiddling around with it, found (/(\w+)/) works for what I want.
[QUOTE=proboardslol;46149674]Make a program that converts a number of one base (say, base 10), and converts it to another base (say, hexadecimal). No using Logarithms[/QUOTE] blam [code]public class BaseConverter { public static String convert(int n, int radix) { String result = ""; int v = 1; while(v <= n/radix) v *= radix; while(v > 0) { if(n < v) result += "0"; else { int place = n/v % radix; if(place < 10) result += place; else switch (place) { case 10: result += "A"; break; case 11: result += "B"; break; case 12: result += "C"; break; case 13: result += "D"; break; case 14: result += "E"; break; case 15: result += "F"; } n -= v; } v /= radix; } return result; } public static void main(String[] args) { int n = 231; System.out.println(convert(n, 2)); System.out.println(convert(n, 10)); System.out.println(convert(n, 16)); } }[/code] [img]http://i.imgur.com/WW7clfS.png[/img] (: [editline]4th October 2014[/editline] Only handles up to base 16, but it's easily modifiable to include more bases.
Write a divide and conquer sorting algorithm.
[QUOTE=FalconKrunch;46150289]Write a divide and conquer sorting algorithm.[/QUOTE] What does that mean?
[QUOTE=NixNax123;46150560]What does that mean?[/QUOTE] A divide and conquer algorithm is one that divides one big task up into smaller tasks until it's trivial to solve, take a look at merge sort or quicksort.
[QUOTE=FalconKrunch;46150611]A divide and conquer algorithm is one that divides one big task up into smaller tasks until it's trivial to solve, take a look at merge sort or quicksort.[/QUOTE] Oh, so like binary sort!
yes
snip
at my mum's engagement party last night, I met a man who owns a large software company and after some talking he said he'll give me a job programming for him over the summer. Now I've got a few months until then and I'm very rusty at C++ so I was hoping that I could get some good resources to brush up. Also he said he has some ideas for a few apps and I don't know how to develop apps. this is a big opportunity for me and I don't want to fuck it up.
[QUOTE=proboardslol;46149674]Make a program that converts a number of one base (say, base 10), and converts it to another base (say, hexadecimal). No using Logarithms[/QUOTE] [img]http://i.imgur.com/0CFjK6w.png[/img] i learned even more by making a GUI for it! (:
[QUOTE=NixNax123;46150024]blam [code]public class BaseConverter { public static String convert(int n, int radix) { String result = ""; int v = 1; while(v <= n/radix) v *= radix; while(v > 0) { if(n < v) result += "0"; else { int place = n/v % radix; if(place < 10) result += place; else switch (place) { case 10: result += "A"; break; case 11: result += "B"; break; case 12: result += "C"; break; case 13: result += "D"; break; case 14: result += "E"; break; case 15: result += "F"; } n -= v; } v /= radix; } return result; } public static void main(String[] args) { int n = 231; System.out.println(convert(n, 2)); System.out.println(convert(n, 10)); System.out.println(convert(n, 16)); } }[/code] [img]http://i.imgur.com/WW7clfS.png[/img] (: [/quote] comment your code d00d [editline]4th October 2014[/editline] [QUOTE=Pat.Lithium;46152077]at my mum's engagement party last night, I met a man who owns a large software company and after some talking he said he'll give me a job programming for him over the summer. Now I've got a few months until then and I'm very rusty at C++ so I was hoping that I could get some good resources to brush up. Also he said he has some ideas for a few apps and I don't know how to develop apps. this is a big opportunity for me and I don't want to fuck it up.[/QUOTE] Am I the only one who has an innate distrust of business types? Like when they say they'll give you a job just for knowing them, I fear it always turns out that they work for vector marketing or some shit edit: read Barney Toasterstrudel
Sorry, you need to Log In to post a reply to this thread.