mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

"You become more and more mature as you age, up to when you're about 20, after that, you just get older." -- Judd Apatow

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

The collision is only inside the model, ...
the normals on the model pointing out as it should be. ...
you can se inside it but not inside out ...
collision works great from the outside. ...
The collision is only intersecting the triangles inside for an example a box. Not from the outside...
To mention the collision is against a world.

These sentences are very confusing, and seemingly self-contradictory. I'm sure it makes sense in your mind, but I certainly can't make heads or tails of it. Please try to explain the issue more clearly.

And I cant have reversed normals on models in the game, it dosent look well.

If what you want is for the faces to appear from both directions, you need to disable "backface culling" (or from gamedev article).

Usually, in 3D modelers like Maya, backface culling is one of the configurations of a material or of the model as a whole. I don't know Maya, so I can't help you.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

had to crawl up the stairs to bed FFS!

lol, I remember having to crawl up the stairs to my hostel room once, but it was a different kind of intoxication... the self-induced kind.

Glad you're OK now.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

This is really a question that you should direct to the developers of that library / program.

If you say that there are already programs (within that framework) which can exchange some data (or "communicate") with the main program, then it means that this framework uses some form of inter-process or inter-program communication. Inter-process communication is usually achieved with things like files (or pseudo-files), memory-mapped files, network sockets (on a loop-back IP address), or pipes (also a kind of pseudo-file), or other OS-specific options. These are language-agnostic. You should enquire as to what method they are using and how to tap into it.

Otherwise (if they are unavailable to help you, which I doubt), you have the source code. Learn enough C++ to understand the relevant parts of that source code and learn to modify it to your needs. Plowing through a library like that is a tedious process regardless of your skill level. But it's not impossible, but it's highly preferrable if you can get guidance / pointers from the library developers directly.

As for book recommendations, we have a permanent thread for that (you can skip to the end for the more up-to-date recommendations).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

If the option is between this:

int row_locs, col_locs;
int row_descriptors, col_descriptors;
double **locs;
double **descriptors;

call_function(row_locs, col_locs, row_descriptors, col_descriptors, locs, descriptors);

and this:

struct return_struct {
    int row_locs, col_locs;
    int row_descriptors, col_descriptors;
    double **locs;
    double **descriptors;
};

return_struct result = call_function();

Then, it depends on whether the function gets inlined or not. If inlined, the two will probably be identical, and I mean, literally identical (same machine code) (or maybe just a different order on the data on the stack). If not inlined, then the second option will probably perform a little bit faster. Like others have said, the performance difference is probably not worth worrying about, until you identify it as a performance issue.

The reason that the second version could be faster is just because it's almost guaranteed that the compiler can do a return-value optimization on a POD type (the struct). What RVO means is that the copy of the return value is optimized away. In other words, the return value (the struct) is constructed directly at the destination, instead of being copied. So, with RVO, there is no copy and no indirection required inside the function (indirection: de-referencing pointers or references). When passing references into a function, the compiler cannot optimize away the indirection unless the function is inlined, so, you avoid the copy for sure but you suffer from indirections (which is not significant overhead, especially if they reference stack-based variables). Passing by value and returning by value will avoid …

deceptikon commented: Good as usual +12
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What's wrong with the Symbian SDKs for Belle?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

"to snap" means to break in half, such as snap a twig (small tree limb). It could also mean to rub the thumb and middle finger together to make a noise -- snap you fingers.

It can also mean to go crazy. "I don't what's wrong with him, he just snapped."

I'm sure that "to snap" has many other regional-dialect meanings in various parts of the world. I think Xantipius will have to clarify what meaning he is referring to. I think I have also heard "to snap something" as meaning "to steal something".

I have never heard the term "snapper" being used.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Isn't is easier to start with Petzold if one is going to program under Windows?

There are a few problems with this. First, GUI programming is not the be all and end all of programming, it's merely a tiny (and rather trivial) subset of it. Second, not everyone targets Windows, and learning C++ and learning Windows programming are two very different things that have to be treated as two separate learning processes. Third, why learn to do specific Windows programming when you can easily learn to use cross-platform tools that develop equivalent skills yet are more durable and useful in industry. Fourth, Petzold's books don't teach C++ at all. The pre-.NET editions teach you about the Win32 API and uses the C programming language (not C++), both of which are interesting for legacy reasons but a largely outdated these days. The post-.NET editions are in C#, with some examples translated to C++/CLI (or C++/CX, or whatever the latest re-branding of Managed-C++ is), neither of which have anything more to do with C++ than Java does, which is a terrible pathway to learning C++. And finally, Petzold himself stresses the fact that these are not books that teach programming, knowledge of programming is assumed prior to reading the books, they are just guides to help a capable programmer find his way around Windows' APIs. So, certainly, this is nowhere to "start with".

And this thread is about books that teach C++ programming, let's keep it to that, otherwise it …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

May I ask that this thread be deleted please?

Short answer. No. It's not our policy to delete threads on request, even of the OP. The point is that this thread might help others and also contains posts that other members have taken the time to write.

May I ask why you want this to be deleted? Especially after so long..

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You can also use the term "public transit".

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

We don't just post solutions. We help people solve the problems on their own.

If you have code that you wrote and you are stuck on a specific issue, just start a new thread.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Then all I need to do is include my header files and link to my library to get access to all my functions?

Yes.

And I can also have a global variable or two in the header file that my library functions can access?

If your headers declare some extern global variables and you have the definition of those global variables in your library's cpp files, then you can access them if you compiled your library as a static link library. Under Windows, you cannot access those variables if the library is compiled into a dynamic link library, regardless of the compiler you use (it's part of the design of DLL system in Windows).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

What you are saying is that a DLL with a properly written c-interface can have its functions (or classes if in c++) called by pretty much any language that supports calling c functions and on most operating systems

Well, if by "most operating systems" you mean "Windows-only" (and probably a relatively recent version of it), then yes. DLLs are only for Windows, and they could use code (via OS calls) that are not supported on older versions. In every other kind of operating system (all Unix-like environments), we don't call them DLLs, we called them "shared object files" (with extension ".so") and they are similar to DLLs, but they are also very different (and far more powerful, actually).

whereas a static link library would only really work for people using MY compiler (or a similar one).

Not exactly. Here again the world is split as Microsoft vs. the World. If you use the Microsoft compiler (MSVC) (with .lib extensions for static libraries), then, yes, static libraries are not compatible between compiler versions, but there are really only a few versions (2008 (MSVC9), 2010 (MSVC10), 2012 or 2012-nov-update (MSVC11)) that anyone would reasonably still use today. All other compilers (except for older Borland compilers) use the Intel C++ ABI standard, and all the C/C++ static libraries (and dynamic libraries) are compatible across all versions since the adoption of that ABI standard. So, in the non-Microsoft world, all these issues we've been discussing don't really exist.

Another thing, …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I have written DLLs and SLLs? before, but I never fully understood them.

Ok. Let's take it from the top. When the compiler compiles each c/cpp file, it generates an object file (usually with extension .o or .obj, depending on the compiler). These object files contain, among other things, a section of compiled code for each function. That section of code is marked with a symbol to identify it (the symbol is usually the function name, possibly with some extra decoration). Any function call in the code usually remains in the object file as a symbol reference, that is, a kind of "this needs to be replaced by a jump to the final address of that function" marker.

Then, the job of the linker is to take all the object files, collect all the symbols into a massive symbol table (i.e., associates symbols with where its corresponding code can be found), and then goes through all the symbol references and replaces them with a jump to the appropriate code (finding the symbol in the table is called resolving the reference (and hence the errors like "unresolved reference to ..."), and replacing the reference with a jump (or call) is called linking).

A static-link library means that the linking is done completely before generating the final executable or DLL. Essentially, a static-link library is just a collection of object files packed together in one file. Linking to a static-link library is pretty much identical to having all the cpp …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I had no idea you could do that little struct myClass thing and actually use a class in there for the c implementation.

In C++, struct and class can be interchanged at will. The only difference between the two is the default access rights (private for class, and public for struct) and the default inheritance (private for class, and public for struct), but these only matter for the declaration of the class/struct (i.e., where you have all the data members and functions). When the same class name appears in multiple places, it is usually because there is one declaration and then a number of other things like forward declarations and friend declarations. In those multiple places, it doesn't matter (strictly speaking) whether you write struct or class. However, some compilers might complain with a warning.

can you just pass a void pointer to the c-style functions and then cast it to a class in the c++ definition of the function? I would have guessed that would be impossible.

There is a requirement in the C++ standard that states that any pointer type can be cast to a void* and that for any type A, a pointer to an object of type A (lets call it a_ptr) can be cast using void* v_ptr = reinterpret_cast< void* >(a_ptr); and then cast back to a pointer to type A, yielding the same as the original pointer, i.e., ( a_ptr == reinterpret_cast< A* >(v_ptr) ) will always be true.

This …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

African or European?

Have you ever been to Disney Land / World?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You are going to have to explain what you are actually trying to achieve, because it's really not clear at all from the code.

Then, there are a few obvious problems, of course.

First, seeing stuff like this:

typedef struct { /*something here*/ } *myNewType;

makes steam come out of my ears. Don't "hide" pointer types behind a typedef, especially not raw pointers, and it's even worse when you don't even mention the fact that it is a pointer in the name of the typedef. Just don't do it. I can live with people doing things like typedef std::shared_ptr< MyClass > MyClassPtr;, because there is a benefit in shortening the type name and passing a shared-pointer around is quite safe. For raw pointers, I say, no way José!

Second, defining a MACRO to replace the main function, well... that's just terrible. Any solution that requires this (or similar nasty hacks) is a bad solution, period.

Third, I'm trying to understand whether you are trying to wrap a C library with some C++ code or whether you are trying to expose a C++ library with a C interface. Although the latter is more usually the case, your code is very odd if that's what you are trying to do. The sort of canonical code for exposing a C++ library via a C-compatible interface goes something like this:

#ifndef MY_CLASS_H
#define MY_CLASS_H

#ifdef __cplusplus

class MyClass {

  /* some C++ code, as usual */
  public: 
    void foo();  // some …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I think it's too big, that's all. Consider this is a heading

Some Heading

and this is a sub-heading:

Sub-heading

I think that the current sub-headings are the size that the headings should be and then have a smaller/different font for the sub-headings. I always thought it was weird to be able to create headings that are the same size as the thread's title.

bguild commented: Agreed! +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

It's the "Heading" format, done with # some text #. I guess we can't really be responsible for people's lack of good taste, if they decide to write some text as a Heading, so be it.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Well, the answer to your problem (but not to your question) is to change your IDE. Dev-C++ is far too old to support C++11. The MinGW GCC version that ships with Dev-C++ is version 3.4.2, which is really old. Decent support for C++11 starts roughly from 4.6.0, but since it is still experimental, the newer the better. Currently, you can get 4.7.1 version through TDM-GCC ports. I recommend switching to CodeBlocks, which you can download as an installer that includes TDM-GCC 4.7.1. That should allow you to have decent C++11 support.

As for setting compiler options, you typically have to navigate the "Build Configuration" or "Project Properties" or similar panels. Usually, you will find a place to put "custom compiler options" where you can place the exact command-line compiler option (like -std=c++11), that is, if you can't find a checkbox for the particular option you need.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

No, because I don't believe in burning about 30 litres of fuel per minute for myself. (that's a poor-man's justification, of course)

Have you ever seen an octopus?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I was just looking a this thread with a lot of quotes (people quoting each other) and there were these really weird graphics (see the attached snapshot).

I'm using Chrome:

Google Chrome   26.0.1410.63 (Official Build 192696) 
OS  Linux 
WebKit  537.31 (@147513)
JavaScript  V8 3.16.14.11
Flash   11.2 r202
User Agent  Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31

a6e878ffd975a92ad73f17a72bb71fae

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Yes, a few times when growing up (my aunt had horses, one of my childhood friend too, and then, the odd field trip now and then).

Have you ever rode a motorcycle?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

While this has been alright for me and those involved in my department, I've been thinking about what problems may arise when someone other than me (in the future) has to analyze and fix the problems. Because of the lack of documentation, future maintainenance will be a big issue if I'm not the one maintaining this beast.

What I always like to remind people too is that there isn't much difference between someone who is a stranger to your code and yourself a few months down the line when you've moved on and don't remember much of the details of the code. So, this is not only going to be an issue if someone other than you has to maintain it, it is also an issue if you have to maintain it later. If in six months you get asked to update or fix some bug in the details of an implementation that you wrote 9 months earlier, will you really be able to just jump right into it? Or will you have to re-learn all about the details of the implementation? Probably the latter.

All that being said, are you thorough with your documentation and do you document every aspect of your projects? Or, do you have a document writer?

It can be quite difficult to keep up with this, I know I have a hard time doing it. It's really a multi-tier system. If I start from the inside, going towards the outside, I …

Stuugie commented: Great post, thank you very much! +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

storage

In formal terms, "static" is a storage-class specifier.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Looks pretty good to me. I'm sure you know that you need to somehow make it easy for them to get access to the websites you did, because that's really the main thing they will want to see.

The typing comment does sound a bit weird, especially in the MS-Word section. Unless you're a secretary taking dictations in the 70s, or a court stenographer, the typing speed is largely irrelevant, purely an by-product of having to do a lot of typing. Think about it, a typical coder will be very happy to write about 1000 lines of code in one day, yet, the average coder could probably type 1000 lines of non-sense code in about 5 minutes, if it takes 10 minutes, it doesn't matter much. It's mostly that if you see someone typing really fast, you know he's been at it for a long time.

Good luck with the job!

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I am always astonished by how far people are willing to go before they even try to understand what they're doing. (quote by me)

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

No, because I work on the principle that if nobody saw me do it, it didn't happen. ;)

Have you ever been the victim of a pick-pocket?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Yes, at the zoo.

Have you ever rolled down a flight of stairs with a bicycle?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Yes, rammed my parents' car into a 2m high snow bank at about 90km/h.

EDIT:

Have you ever been injured while cooking.

Yes, I once spilled boiling bacon fat on my hand and ended up with a 3inch diameter burn water bell.

Have you ever been stung by a gelly fish?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Inheritance in C++ is pretty much the same as inheritance in OOP. I could hardly explain any more than the wiki page does. If you have a more specific problem, just ask.

The types of inheritance in C++... well, that depends a bit. There are different categories depending on the point of view. Computer science academic people have all sorts of fancy terms, since they spend most of their time putting labels on things, while programmers just do what seems right without caring much about how it's called. From a more technical point of view, in C++, you can do public inheritance, private inheritance, multiple inheritance, virtual inheritance, and a few more special tricks (a bit too advanced for now). Of course, only "public inheritance" is what is generally meant by the narrow concept of "inheritance in OOP".

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Yes, my brother's.

Have you ever been to Grand Canyon?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

For a linked list, the easiest is probably to save all the nodes (without the pointers) sequentially in the file, and then reconstruct the linked-list when loading the elements.

I suggest you read up the documentation of Boost.Serialization to understand the logic of doing saving/loading of objects. Naively doing is.read(reinterpret_cast<char*>(&o3), sizeof(a) ) is not correct or robust in general, even for primitive types (i.e., because of endianness).

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

No, I'm too afraid the plane might crash.

Have you ever been on TV?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I am a billionaire! .... Well, if I count everything in Vietnamese Dongs!

Have you ever crossed a polar circle?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Only on snow ;)

Have you ever won a gold medal?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I believe that the problem is due to the fact that you installed the grub bootloader on the MBR (Master Boot Record), overwriting the Windows bootloader. This is the default configuration when installing Ubuntu (and most other distro) since this is what you need when you install Ubuntu only (but also works with a Windows partition on the side). I generally don't like this and recommend not to do it. Instead, the grub bootloader should be installed on the Linux partition itself and the Windows bootloader should be kept in the MBR (adding an entry to chain-boot to grub on the Linux partition). This is what you did wrong, and the reason why it is broken now is because even though grub was on the MBR, its configurations were on the Linux partition that you deleted. So, now, you have grub starting but finding no configuration and thus the error message.

To fix the problem, there are a number of possible solutions. On this site, they have some simple instructions for recovering the Windows 7 bootloader, which requires having a Windows 7 recovery disk (or live USB). I think that if you have a Linux LiveCD (or USB) (like the one you used to install Ubuntu in the first place), you should be able to find the "Windows" option in the grub menu when you boot from that LiveCD/USB, and once you are in Windows, you can restore the bootloader with whatever program you choose, such as EasyBCD …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Yes, but it didn't lift off the rack.

Have you ever attended a pow wow?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

No.

Have you ever flown an airplane?

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

You cannot open a file in append mode (std::ios::app) to read from it (input). Technically speaking, it doesn't make much sense to open a file for "appended read operations". As far as the C++ standard goes, it says that this is implementation-defined (i.e., will behave differently depending on the system). Some implementations will just ignore the "append mode" request, and open it normally. Some implementations will refuse to open the file (which is what I suspect is happening here). And some implementations will open the file and move the read-position to the end of the file (making the very first read operation hit the "end-of-file" marker). In other words, don't open an input file-stream in append mode.

N.B.: the vagueness comes from the fact that files in different systems (Windows vs. POSIX) behave differently, and there couldn't be a consensus, so it was left as "implementation-defined". In practical terms, it means you can't reliably use it.

When a file is not opened, the read operation leaves the memory unaltered, which explains the "garbage" values that you see (i.e., uninitialized data). Try this:

a o3,o4;
ifstream is("test.txt", ios::binary | ios::app);
if( is ) {
  if( is.read(reinterpret_cast<char*>(&o3), sizeof(a) ) )
    cout << "o3.get() => " << o3.get() << endl;
  else
    cout << "Read operation on input stream failed!" << endl;
} else {
  cout << "Input stream could not be opened!" << endl;
};

My guess is that you will get one of those two error messages to print out.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I guess it's true that Linux does require a bit of an initial push, like being forced to use it for some job or project. As exemplified by some of the posters here, if you just install Linux to try it out, with no real purpose or reason for just pushing through some of the initial bumps on the road (some inevitable config tweeks, "strange" software that you're not used to, and re-learning some basic skills that you take for granted on the OS you're used to), then you can easily get cold feet or just lose interest. But once you went past the initial steep hill, it really is a wonderful system, in my opinion. It's far more rare to hear people who used Linux for a good amount of time as a primary OS and decided to go back to Windows or Mac. I compare it a little bit to LaTeX vs. MS-Word, most people are initially scared and confused when using LaTeX, but most people who do a lot of technical writing (theses, scientific articles, etc.) swear only by LaTeX. MS-Word is easy to adopt, but constantly aggravating, while LaTeX is hard to adopt, but smooth sailing and impeccable afterwards.

There are things that are just so easy with Linux it's not even funny. For example, I remember some years ago I was writing an engineering report for which I had to collect a bunch of images into a single pdf file. It was such a pain-staking …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

I guess I agree with Labdabeta.

It's a matter of balance. There are things that you need to code, and there are things that would be really stupid to do via code.

The reason why drag-drop GUI designers exist is because it is really asinine to do all that in the form of code. For example, if I'm creating a notepad application, I need the edit area to be resized every time the window is resized, i.e., it should fill the window. I could code this up via an "OnResize" event with code to update the size and placement of the edit area within the resized window area. But doing this would be a waste of time, if all I need to do is check a checkbox in a GUI designer to tell it that I want that component to expand along with its parent window. And then, I won't even talk about how wasteful it would be to actually have huge lengths of code that just place components at the right place and resize and all that stuff. Doing all that stuff via code is like creating a 3D model with lots of code that creates the mesh with hard-coded points. When you think of it that way, and know how stupid it would be to create your 3D models like that, you realize why drag-drop GUI designers are good and what they should be used for.

And then, of course, you have stuff you need to do with …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

As you say, there is a weird quirk about access to protected members. You can only call protected member functions on the "this" object, from a derived class. I don't know the reason behind this (if any), but it seems like a stupid rule to me.

In any case, you can circumvent the rule very easily, in many ways. This access rule applies only to calling protected non-static member functions, meaning that you can circumvent it by using anything else, like a protected data member, a protected nested class, or a protected static member function. Pick your poison.

Here are two options:

//main.cpp

#define USE_OPTION_1
//#define USE_OPTION_2

class UIObject
{
public:
   virtual ~UIObject() { }

   /* UIObject API */

protected:
   UIObject( UIObject* pParent )
   :
      m_pParent(pParent)
   {
   }

   virtual void onParentOrphan()
   {
      m_pParent = 0;
   }

   virtual void onParentAttach( UIObject* pParent )
   {
      m_pParent = pParent;
   }

#ifdef USE_OPTION_1
   struct ParentConnector {
      UIObject* m_pChild;
      ParentConnector(UIObject* pChild) : m_pChild(pChild) {};
      void makeOrphan() const {
         m_pChild->onParentOrphan();
      };
      void attachParent(UIObject* pParent) const {
         m_pChild->onParentAttach(pParent);
      };
   };
#endif

#ifdef USE_OPTION_2
   static void callOnParentOrphan( UIObject* pChild ) {
      pChild->onParentOrphan();
   };

   static void callOnParentAttach( UIObject* pChild, UIObject* pParent ) {
      pChild->onParentAttach(pParent);
   };
#endif

   /* parent */
   UIObject* m_pParent;
};

class Panel : public UIObject
{
public:
   virtual ~Panel() { }

   /* panel methods */
   virtual void add( UIObject* pChild ) = 0;

protected:
   Panel()
   :
      UIObject(0)
   {
   }
};

class SimplePanel : public Panel
{
   SimplePanel() { }
   virtual ~SimplePanel() { }

   virtual void add( …
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

The nastier case

Actually, the new law makes things better in this particular example. Before the law, the company had the following options:

1) Not use your works, i.e., find something else to put in their marketing material.
2) Pay royalties to you for using your works.
3) (illegal) Strip the meta-data from the works and use it without telling anyone.
4) (illegal) Strip the meta-data from the works, forge their own meta-data onto it, and use it while claiming it's their original works.

This law adds a fifth option:

5) (illegal) Strip the meta-data from the works, register it as orphan, and use it while paying a nominal royalty into a reserved fund.

When it comes to option 1 to 4, the new law does not have any effect at all. And in the options 3 and 4, you are likely going to have a hard time in court trying to prove that the works are your own, and I agree that this is a problem, however, it is a problem that is completely unrelated to and unaffected by the new law. However, in the off-chance that a (very stupid) company actually chooses option 5, it will actually be easier to "prove" that the works are your own, because there is no-one else claiming ownership of the work. The company registered it as "not their works" and the royalty money has already been set aside by the time you show up with a claim, …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Everyone knows only a minority of the internet generation votes so hardly any politicians will even hand out platitudes to them.

I would say there is much more evidence that most politicians are completely oblivious to the concerns of the "internet generation", whether it would be in there interest (attracting votes) or not. They simply do not understand this "new" world, and so, at best, they do what they are told, most often by large companies who do understand this "new" world and want to take advantage of it by bending the rules in their favor. And if the "internet generation" doesn't vote as much (which I'm not convinced of, btw), it is largely because of that, i.e., they don't see politicians as representing them at all. As far as I'm concerned, politicians are neanderthals in the age of technology.

For example, in Canada, our minister of science and technology, which I have met recently, is a chiropractor. In other words, the best we can do in terms of having someone who understands science and technology is a person who clings to a pseudo-scientific practice from the 19th century. I think that's a perfect symbol for this whole problem.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

So if someone gets ahold of some of your code and uses it themselves, stripping any header/licence content in the process, how do you prove it's yours?

Simple, use this command:

$ sim_text their_code/src/* / my_code/src/*

or any other code-duplication detection tool. But the problem is, of course, to be able to force the company to allow this kind of scrutiny to be applied to their source code, this is a problem of "probable cause", meaning you must have strong suspicions and be able to show that it is reasonable for you to have strong suspicions, and thus, be allowed to perform such a verification to see if some of their source code is actually yours.

This is the big problem with "hidden" works like that. I think that at the very least, for engineering or software, if a company actually wants to make use of orphan work, they should also be required to make that public and make the work publicly available. But again, with such laws, there would be no reason for any company, unless mentally challenged, to actually do this.

Like you said in your example, if you have work, even unpublished work, it can be classified as an orphan if it has no meta-data to identify the owner, or if the owner cannot be verified after a "diligent" search.

I don't really think that companies would have much reason to register their stolen works as orphan, especially in the case of …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

if I read it right, the problem with the law is that anyone can himself orphan a work by removing prior ownership information, effectively legalising content piracy.

No, that's not what it means. The copyright notice / meta-data does not carry the copyrights, it is only relevant in finding the person who has it. Removing that information doesn't make it legal to own or use the material, it simply makes it look legal under the most superficial examination.

The copyrights are always carried by the content, to remove the copyright would mean to remove the content, thus defeating the whole purpose. For example, if I write a song, my copyrights are carried by the melody and the lyrics, anyone who reproduces or distributes a song with the same melody and lyrics without my consent is infringing my copyrights. The ownership information or meta-data are irrelevant. However, if I produce my song to iTunes with meta-data identifying me as the owner of the copyright, it certainly makes it easier for people to know who to contact to pay royalties if they want to use it.

Find a movie, strip the copyright and trademark information, add your own, and it's now yours.

No. It doesn't work that way at all, that would be quite ridiculous. If I download a movie illegally, strip away whatever copyright / trademark information in it, I still cannot claim that I made this movie entirely by myself. Just like I cannot claim to …

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

NathanOliver's suggestion is reasonable:

If that is the case then I would split you main array into seperate arrays for each type. Then sort those arrays in descending order. Then find which array has the highest sum for the first three elements.

Although you can also do it all in one go, using lexicographic sorting. In other words, sort by type first and by value next, with something like this:

bool compareItems(const Item& lhs, const Item& rhs) {
  if( lhs.type() == rhs.type() )
    return lhs.value() < rhs.value();
  else
    return lhs.type() < rhs.type();
};

If you sort the entire array, it will be split in terms of types, and then in terms of values, at which point you just need to pick out the top three values of each type groups, and find the highest sum.

However, this method is a bit too heavy-duty for my taste. I would go with a much simpler method. Really, all you need to do is keep track of the top three elements for each type, so, just do that directly. Go through the array once, keeping track of those elements, and at the end, go through what you have recorded to find the highest sum. You can even keep track of the highest sum the first time around too.

mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

At first glance, the whole "Option 0: Do nothing" versus "Option 1: Do what I propose" just reeks of false dichotomy. If I was a law-maker I would dismiss the proposal on that basis alone. There is no way that a serious person doing a serious proposal would have found that there are only two possible options, nothing and his own idea. Law-makers passing this show a great lack of basic critical thinking skills, they ought to be ashamed in requiring such a low standard for what a serious proposal is. Not to mention that the document itself looks like it was drafted by a high-school student.

That said, I don't disagree too much with the proposal / law, per se. It is clearly directed more towards the classic preconception of "orphan work" as kind of old footage, recordings or pictures, that people might want to use as part of a documentary or something. I think the provisions are OK for those purposes. But, obviously, the issue is complicated by the fact that in our insane IP-landscape, things like software are also under the same copyright classification as these works of arts, when, clearly, these are apples and oranges.

The problem with something like software development is that I can write some open-source code (say, under GPLv2 or GPLv3), and then a company can grab that code, strip away the license notices and meta-data in the files, and use it to create some closed-source application, and I will probably never …

Ketsuekiame commented: Good analysis. +0
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster

Or check in http://slackbuilds.org/ there may be Libreoffice.

Indeed, there is.

If all else fails, you can always compile it from sources.