Meeting with Bjarne Stroustrup
Sunday, 8. November 2009, 01:01:21
The Royal C++ Embassy
Sunday, 8. November 2009, 01:01:21
Sunday, 6. September 2009, 23:18:14
Saturday, 13. September 2008, 00:20:00
Tuesday, 22. January 2008, 02:35:33
Tuesday, 15. May 2007, 21:46:54
Thursday, 29. March 2007, 00:20:22
Wednesday, 4. October 2006, 01:15:32
Sunday, 3. September 2006, 01:05:14
typedef void* HDATA; // some data "handle" HDATA CreateData(const wchar_t** pwszArguments, int iArgs); int DecodeData(HDATA h, wchar_t* pbuf, int cchbuf); // use handle returned by above function
class DataClass
{
public:
void foo();
int bar();
DataClass* baz();
};
HDATA CreateData(const wchar_t** pwszArguments, int iArgs)
{
HDATA h;
DataClass* pcls;
// do something with pcls
h = (HDATA)pcls;
return h; // return pointer to a DataClass object.
}
int DecodeData(HDATA h, wchar_t* pbuf, int cchbuf)
{
DataClass* pcls = (DataClass*)h;
return pcls->DecodeData(pbuf, cchbuf);
}
template<typename T>
class SomeClass
{
public:
bool some_method(T& t)
{
// do something
}
void foo(T& t)
{
// ...
}
};
typedef std::vector<int> MyVectorType;
MyVectorType g_vec;
void foo(int i)
{
SomeClass<MyVectorType::value_type> sc;
some_method(g_vec[0]);
}
class Base
{
virtual void foo() = 0;
virtual void bar();
public:
void f();
};
class Derived
{
// implicit virtual
void foo()
{
}
public:
void f();
};
void test(Base* pbase)
{
pbase->foo();
pbase->bar();
pbase->f();
}
void polycall()
{
Derived d;
test(&d);
}
Hmmm...
// Vendor code
class DataAcquirer
{
public:
// can conflict with customer's code?
DataAcquirer& operator<<(int i);
// can customer refuse/modify this data?
virtual void OnDataArrived(const Data& rdata);
// yet another string class... perhaps, this is "more efficient"...
VendorString GetDataSource();
// did they override operator new, too??
};
// too complicated for average C++ programmer.
// may be nightmare for new graduates!
template<typename T, template<class, class> class TSomeContainer, typename TTraits = SomeTraits>
class SomeTemplate : public SomeBase<T, TSomeTraits>
{
TSomeContainer<T, LibraryAllocator<T> > m_arr;
public:
typedef typename SomeBase<T, TSomeTraits>::some_type some_type;
};
Sunday, 27. August 2006, 12:00:00
ISomeInterface *psi;
psi = NULL;
HRESULT hr = CoCreateInstance(CLSID_Application, NULL,
CLSCTX_INPROC_SERVER,
IID_ISomeInterface,
(void**)&psi);
HRESULT hr = CoCreateInstance(__uuidof(Application),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(ISomeInterface),
(void**)&psi);
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("00000000-0000-0000-C000-000000000046")
IUnknown
{
public:
BEGIN_INTERFACE
virtual HRESULT STDMETHODCALLTYPE QueryInterface
(REFIID riid, void **ppvObject) = 0;
virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;
virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
END_INTERFACE
};
#else /* C style interface */
typedef struct IUnknownVtbl
{
BEGIN_INTERFACE
HRESULT (STDMETHODCALLTYPE *QueryInterface)(IUnknown *This,
REFIID riid, void **ppvObject);
ULONG (STDMETHODCALLTYPE *AddRef)(IUnknown *This);
ULONG (STDMETHODCALLTYPE *Release)(IUnknown *This);
END_INTERFACE
} IUnknownVtbl;
interface IUnknown
{
CONST_VTBL struct IUnknownVtbl *lpVtbl;
};
#endif
// expre_uuidof.cpp
// compile with: ole32.lib
#include "stdio.h"
#include "windows.h"
[emitidl];
[module(name="MyLib")];
[export]
struct stuff {
int i;
};
int main() {
LPOLESTR lpolestr;
StringFromCLSID(__uuidof(MyLib), &lpolestr);
wprintf_s(L"%s", lpolestr);
CoTaskMemFree(lpolestr);
}
#import "SomeLibrary.dll" no_namespace raw_interfaces_only
Friday, 25. August 2006, 23:38:05
#include <iostream>
using std::cout;
using std::endl;
class X
{
public:
int Add(int)
{
cout << "X::Add(int)" << endl;
return 0;
}
int Add(X&)
{
cout << "X::Add(X&)" << endl;
return 0;
}
};
class D : public X
{
public:
int Add(char) // Hides base's Add method(s)
{
cout << "D::Add(char)" << endl;
return 0;
}
};
int main()
{
X x;
x.Add(x); // OK: X::Add(X&)
x.Add(3); // OK: X::Add(int);
D d;
d.Add('c'); // OK: D::Add(char)
d.Add(1); // Error: overloads are hidden
d.Add(x); // Error: overloads are hidden
return 0;
}
class D;
template<typename T>
class X
{
public:
template<typename U>
int Add(U u)
{
T* pt = static_cast<T*>(this);
// force derived class to implement AddItem for each U
return pt->AddItem(u);
}
};
// char, specialization.
template<>
template<>
int X<D>::Add<char>(char c)
{
// add it
return 0;
}
class X
{
virtual int AddChar() = 0;
virtual int AddInt() = 0;
// .. others
public:
int Add(char c)
{
return AddChar();
}
};
class D /* : public X */
{
X* m_px;
public:
int Add(char c)
{
return m_px->Add(c);
}
};
Showing posts 1 - 10 of 19.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
| ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | |||||
If you are an aviation enthusiast and want to fly with "human" ATCs "human" pilots, don't miss VATSIM.
You can watch or download various aviation videos.
Pretty big source and library for aviation enthusiast.
Turkish flight simulation portal.
Are you skilled enough to fly with Lufthansa VA? I am!
Source for sim-pilots interested in Turkish airspace or training material.
Navigation Update Service for Flight Simulations. Download latest AIRAC, SID/STARs to your sim.
Source for any kind of C++ question.
Herb Sutter's web site.