Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Not So Fast
Dec 27, 2007


At the moment, I'm getting a lot of linker errors when Visual Studio is trying to build a class template. The code compiles fine and dandy, but linker errors are too confusing for me to deduce. The template takes in two types, like so:

code:
List<Node, string>	craftlist;
but I get the same linker error messages when I reduce it to a single class template, so I know it's not the fact that I'm using multiple typenames.

I'm getting LNK2019 errors. I've looked on the Microsoft resource website, but I couldn't see any similarity between the examples they gave and what I was doing.

The errors:

http://pastebin.ca/935705

So my question is, where do I start if I want to fix these errors? As far as I can tell, all my code is spelled correctly.

EDIT: Moved the errors to pastebin to avoid table breaking.

Not So Fast fucked around with this message at 22:10 on Mar 9, 2008

Adbot
ADBOT LOVES YOU

Not So Fast
Dec 27, 2007


Ah, that fixed it, thanks. Yeah, I had the functions defined in a .cpp file, but didn't realise that it wasn't referenced at all in the header file or the main source code.

Not So Fast
Dec 27, 2007


shrughes posted:

No no no no no no no no no no no no no no no no no.

This is crazy, you're retarded, etc.

I sadly see this a lot at my workplace. Is there any reason why deriving from a vector is a super-bad idea?

Not So Fast
Dec 27, 2007


I'm working on a C++/CLI project that incorporates some older MFC dialogs for legacy purposes. I also have a new dialog that inherits from the System::Windows::Forms Form class. Is there a way to get the new dialog to be a child of one of the older MFC dialogs, so that modal properties of blocking access to the parent window works properly?

So far, I've tried using NativeWindow / Control's FromHandle function together with the CWnd HWND handle and passing that into the Form's ShowDialog function. This doesn't seem to work though.

Not So Fast
Dec 27, 2007


giogadi posted:

Now this is an excellent question. It’s your terrible class’s fault for failing to motivate this stuff. Of course you hate it if you don’t even know why you’re mucking around in it.

There are a million uses for bitwise operations. One of the fun uses is that sometimes, you can store data in bits way more efficiently than anything else.

For example, if you have a long array of data, where some items are occupied/valid and other items are empty/invalid, you can store the occupied/empty status of each element in a big ol’ bitstring. This is more efficient than storing a bool for each item because a bool is usually at least 8 bits.

Then you can do clever stuff like iterating over only the occupied items way faster than if you were iterating one-by-one over each item and checking “is this occupied or not?”

This is all fancy stuff to squeeze out performance/space. Probably most fancy bit operations are for this kind of thing. You also need to do bitwise operations when working in embedded systems or communicating with hardware without a fancy high-level api.

This is exactly how low bitrate transmission of data works at my workplace, where we are getting up streams of data from tools that communicate by sending up pulses through mud.

Adbot
ADBOT LOVES YOU

Not So Fast
Dec 27, 2007


Strong Sauce posted:

Okay so I posted in August or so about starting a new project in C++, something I've not worked in since my high school days.

My current progress: how the hell am i suppose to know any of this poo poo in C++?

We were able to find someone in our company who is experienced with C++ to take a look at our PRs and he has been pretty helpful.

I wrote a class as a simple storage class. Basically a dict to handle values. I created basic constructor/destructor functions that didn't do anything so I left them blank.

He wrote up a whole thing suggesting how we should set those constructors/destructors to default (i.e. `Dict() = default;`, `~Dict() = default;`) because this allows the memory APIs to be able to set std::is_trivially_copyable_v<T> to return true. This apparently allows std::memcpy, and std::memmove to copy the object faster. He also says even if you're not using your class for much, this is just good practice in his opinion.

I guess my question is: regardless of what you think about his opinion.. is this something I should actually know while I'm working in C++? granted I've only been doing this for maybe half a year but is this just how it is with C++? As you write more code you just kinda figure out these details about C++?

I'm not sure exactly if I just haven't studied enough about C++ or this is just how it is until you gain enough experience writing C++ code. Interested in what people have to say because it just seems like something you'd never know about until you ran into it.

When I posted in here originally people suggested I look at cppreference.com which I went to look at after I found out about that tidbit above and lo and behold it does mention it in the Classes section of the site about triviality, but short of looking for this information I probably wouldn't have found it. Hell even reading that section, I probably would have read it, thought, "okay I guess I need to know about this" but probably would have written my code the same way.

There's a series of books by Steve Meyers (Effective C++ etc.) that collect a bunch of his articles on best practices for using the "new" C++11 features, that are an invaluable extension of just using cppreference or SO.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply