Friday November 13, 2009
You can't modify a
const can you? Well technically no, but there is one place (before a
constructor) where you can. If the parameter used to construct an instance of the Example class is 0 then it allocates an 80 char string and frees it in the destructor.
#include <iostream>
class Example
{
private:
const char * ptr;
const bool freeable;
public:
Example(const char * optional):
ptr( optional ? optional : new char [80]),
freeable( optional ? false : true ) {}
~Example( ) { if (freeable) delete[] ptr; }
void ViewState(char ID) {
if (freeable)
std::cout << ID << " is Freeable" << std::endl;
else
std::cout << ID << " is not Freeable" << std::endl;
}
};
int main(int argc, char * argv[])
{
Example S(0) ;
Example T("Hello World") ;
S.ViewState('S') ;
T.ViewState('T') ;
return 0;
}
So S is freeable, T is not.
Thursday November 12, 2009
By coincidence, last night I was at a Facebook Developer Garage event (in London).
The coincidence is that the .NET Facebook software, which had been getting left behind has just been relaunched at version 3.0. Here is a link to Download it. Facebook has just made a lot of changes to their platform and that all goes live in the next month. The toolkit now includes dlls for Silverlight and ASP.NET MVC (as well as the ASP.NET one) and WPF. If you are developing Facebook applications for .NET then you'll need these. Once I've done a bit more with my code, I'll publish articles and tutorials for it.
Wednesday November 11, 2009
Anything Google does in code is worthy of attention and a new programming language more so. Both Microsoft and Google have a lot of very bright people but with Google it's more likely to be producing open source as this is. Started in September 2007, Go is an experimental OO Lite (no inheritance) language that tries to break away from Java and C++ . It's best summed up as a concurrent, garbage-collected language with fast compilation.
By experimental I suspect they mean it's here to stay but isn't quite finished yet. With built in features like Garbage Collection and parallel computation without having to write threaded code so it supports multi-core out of the box.
The language is interesting. For example, variable declarations are more like the Pascal model with the type after the variable name. This declares two pointers to an int.
var a, b *int;
This is for Linux/Mac mainly, so possibly it would run under Windows using Cygwin/MingW. Gccgo has a C++ front-end with a recursive descent parser coupled to the standard GCC back end. Gc is written in C using yacc/bison for the parser. No header files but instead, just put a load of files in a directory and they can compile together and make cross file calls without needing declarations.
There's a fair deal of documentation and instructions on how to install and run it. It's early days so it lacks tools like an IDE and debugger but no doubt those are in the works. For some "strange" reason they think ogle would be a good name for the debugger as in "go ogle". It must be an anagram...!
Tuesday November 10, 2009
Augmented Reality (AR) is a new buzzword at the moment with several iPhone apps available. It's a simple idea, determine what a camera is looking at and add additional information onto the display. So you point your iPhone 3GS (The latest one with a compass) and it uses GPS and direction information to suss where you are at what you are looking at. It then adds information (e.g. StarBucks) over the live camera image on the screen. It's great for guide books!
But there are other uses of AR and for computer users with a camera there's the GPLed multiplatform library (Windows, Linux, Mac OS X, SGI) ARToolkit with a C API. This was originally developed by Dr. Hirokazu Kato, and is now supported by the Human Interface Technology Laboratory (HIT Lab) at the University of Washington, HIT Lab NZ at the University of Canterbury, New Zealand, and ARToolworks, Inc, Seattle.
It picks up images from a camera and tracks markers (square areas) where it superimposes images. The projects page lets you see what people have done with the toolkit.