Virtual Inheritance
Hello,
I am unable to find any decent article on multiple inheritance.
Can someone point me to the same?
I am specifically interested in implementation details of virtual
inheritance.
(i.e. how are the objects laid out in memory, how is the virtual
pointer table made etc.
Thanks...
|
9/8/2010 3:57:34 PM
|
0
|
"C++" <tech.login....@gmail.com>
|
|
|
c++ programmers' salaries
Hello, I'm Alberto from Italy, and I would be glad to know if it's
true that a good C++ programmer is very well payed in the U.S.A. and
in Australia.
Thanks,
Alberto.
|
9/8/2010 2:19:08 PM
|
3
|
a m <albe...@nomail.com>
|
Information on dealing sensible information?
I need to find some information on how a program can deal sensible
information on users' computers in such a way that it is not directly
accessible and/or modifiable? Any information is appreciated. Thanks
|
9/8/2010 12:11:55 PM
|
0
|
Alexander <alva...@gmail.com>
|
Why Insulation is a Good Investment
Why Insulation is a Good Investment
Investing in products to make homes more energy efficient pays
significant dividends over a lifetime =97 with none of the wild
fluctuations of Wall Street. Insulation contributes to:
- Greater comfort
- Even temperature distribution
- Improved acoustics
- Better moisture control, which can reduce floor squeaks, drywall
cracks, structure damage and condensation
- Potential for increased resale value: Installing proper insulation
levels can also make your home more attractive to potential buyers.
In fact, most buyers list energy-efficiency as a
|
9/8/2010 12:15:51 PM
|
0
|
"......" <sustainable.future...@gmail.com>
|
Multiple headers, but one function body
Hi all,
I'm porting a library to a cpp research compiler. Unfortunately
compiler support for templates is limited and I must create
specialised versions of each template function I come across. This
ends up with a lot of code duplicated by hand. I'm looking for a quick
way to do this automatically, that I can easily remove; likely in a
few weeks.
A toy example: Given,
template <typename T> void foo(T x) { std::cout << x <<
std::endl; }
I must create:
template <> void foo(int x) { std::cout << x << std::endl; }
template <> void foo(float x) { std::cout << x << s
|
9/8/2010 11:46:30 AM
|
1
|
PGK <graham.k...@gmail.com>
|
optimizing the integer rescaling
Hello,
I am trying to optimize integer rescaling (see example at the end).
There is a range or integer elements (in the example, elements are of
type unsigned short), current range maximum, and the desired maximum.
Straight forward way is to multiply by new maximum, and then to divide
by old maximum (taking care about the overflow).
Are there better ways of rescaling the integers?
///////////////////////////////////
#include <iostream>
unsigned short a = 0x1234; // value in the range to rescale
unsigned short b = 0x3fff; // new maximum range value
unsigned short c
|
9/8/2010 10:43:30 AM
|
8
|
Vladimir Jovic <vladasp...@gmail.com>
|
Why Insulation is a Good Investment
Why Insulation is a Good Investment
Investing in products to make homes more energy efficient pays
significant dividends over a lifetime =97 with none of the wild
fluctuations of Wall Street. Insulation contributes to:
Greater comfort
Even temperature distribution
Improved acoustics
Better moisture control, which can reduce floor squeaks, drywall
cracks, structure damage and condensation
Potential for increased resale value: Installing proper insulation
levels can also make your home more attractive to potential buyers.
In fact, most buyers list energy-efficiency as a prime con
|
9/8/2010 10:52:33 AM
|
0
|
"......" <sustainable.future...@gmail.com>
|
Why is it printing ABC
string func()
{
string msg="ABC";
return msg;
}
int main()
{
string s;
s=func();
cout<<s;
return 0;
}
The program prints s as "ABC", but msg was a local string of func()
and not of main & hence the output should have been any garbage value
but not the same string as "ABC".
Is it occuring because on the top of the stack(that gets generated on
function call), the value of msg remains and it is assigned to
variable s??
But then, if I want to verify that, how can I call another function in
between the call to func() and assignment of the returned value to s??
or if th
|
9/8/2010 8:48:17 AM
|
2
|
Sachin Midha <sachinmidha1...@gmail.com>
|
find_last_of
Hi
I need this not only for Win/Lin but also for Mac. So it's fine for /
and \ within paths but how should I add the old : which were used once
for mac paths?
Many thanks
Michael
string Texstr = filepath;
string::size_type n = Texstr.find_last_of("/\\\:");
|
9/8/2010 7:27:26 AM
|
2
|
Mike <michael.sg...@gmail.com>
|
Get TYPE* array from vector<TYPE> - is this OK?
Hi all!
Given:
std::vector<TYPE> v;
void process(size_t count, TYPE* data);
Is there any problem if I do
if (!v.empty())
{
std::vector<TYPE>::reference r = *v.begin();
// or
r = v[0];
// or
r = v.at(0);
process_raw(v.size(), &p);
}
?
(This is what I do all the time to interface with lower-level code,
but I've always been wondering if there's some issue in doing things
like these).
TIA,
Goran.
|
9/7/2010 1:26:31 PM
|
4
|
Goran Pusic <gor...@cse-semaphore.com>
|
Can I pass auto_ptr in this way?
hi, there,
Can I pass auto_ptr in the following manner?
auto_ptr<T> obj; // The obj is not initialized and null here, right?
function(obj);
// Do I get the initialized obj here?
void function(auto_ptr<T> obj){// can I pass a null auto_ptr into the
function and get initialized inside?
obj(new T());
}
Thanks a lot.
zl2k
|
9/7/2010 3:08:39 AM
|
4
|
zl2k <kdsfin...@gmail.com>
|
what does ## operator does in C ?
I just want to know the function of ## operator.
|
9/6/2010 5:16:13 PM
|
0
|
knight <vimal3...@gmail.com>
|
strange problem in compilation
hi, i'm a newbie of c++ and i have a strange problem with compiling a
c++ source
kdeveloper, gcc 4.2.4, slack.
i've 2 files, S3.cpp and S3.h
s3.h:
#include <ncurses.h>
#include <strings.h>
#include <stdio.h>
#include <vector>
#include <form.h>
using namespace std;
....
class campo
{
public:
campo()
{
fldInp=new_field(1, 1, 1, 1, 0, 0);
}
campo(int intXInp, int intYInp, int intLungInp, int intAltInp,
TipoCampo tcInp,InputCampo icInp, char *chrInit)
{
fldInp=new_field(intAltInp, intLungInp, intYInp, intXInp, 0, 0);
};
private:
F
|
9/6/2010 8:06:04 PM
|
6
|
"Massimo M." <massimo...@gmail.com>
|
Calling const-members
Hi again! I am still learning through examples, and still I am
struggling with matrix classes! :)
I have a probably naive question: how do I "force" C++ to use a const
member? I mean, I have learned (through your suggestions) about const
members, for example my at() member in the matrix class:
class matrix
{
public:
matrix(unsigned int rows, unsigned int cols);
matrix(matrix const& src);
virtual ~matrix();
virtual double& at(unsigned int r, unsigned int c);
virtual double at(unsigned int r, unsigned int c) const;
// ...
}
Now, when I print
|
9/6/2010 12:27:15 PM
|
4
|
et al. <et....@google.mail.com>
|
is a typedef necessary?
Hello all,
I have recently experimented (just for experiment's sake) with
declaring variables and functions of arbitrarily complicated types
without using typedefs, and finally learned to do it. By saying
arbitrarily complicated, I DO mean arbitrarily complicated :). This
led me to believe that any piece of code(let's precautiously add
"which doesn't involve templates") can be rewritten without using
typedefs. But...
struct IncrementFunctorClassWithNoOperatorParentheses
{
static int f(int n) { return n+1; }
typedef int(*pf) (int);
operator pf () { return &f; }
};
One
|
9/6/2010 10:05:26 AM
|
8
|
Armen Tsirunyan <lordn3m...@gmail.com>
|
How to access elements of a range in a vector??
Hi,
I want to do a task of modifying the elements in a range, say 5th
element to 10th element.. I also know that there is a function
TRANSFORM which is used to transform the elements of any container,
say a vector, but in that function, the arguments are iterators, and
what I have is a range and not iterators to these elements.
Eg
vector<int> v;
v.transform(v.begin(),v.end(),v.begin(),modifying_func);
//this, I want to apply not from begin to end, but from say, element
at index i to index j;
//similarly, if I want to know the values in a range of vector or
list, not from begin to
|
9/6/2010 9:11:33 AM
|
3
|
Sachin <sachinmidha1...@gmail.com>
|
how to organize my files/projects properly?
Hi,
I wrote a utility class, say Util, which will be used by several
projects.
It's like the following senario:
Util.h, Util.cpp --> will be used by project A, project B.
option1: I can make Util.cpp a dll, which can be shared by A and by B.
--> but exporting a class is not good, also not elegant.
option2: I can put a Util.cpp in A and B.
--> obviously bad because I need to change Util.cpp in every
projects if necessary.
option3: I can put the implementation in Util.cpp to Util.h, i.e.,
merging the two files into one -- Util.h
--> also seems bad becau
|
9/6/2010 7:30:57 AM
|
4
|
thomas <freshtho...@gmail.com>
|
Range-based for loop and ADL
Range-based for loop description says 6.5.4/1:
"... begin-expr and end-expr are begin(__range) and end(__range),
respectively, where begin and end are looked up with argument-dependent
lookup (3.4.2)."
And 3.4.2 says at 3.4.2/3:
"Let X be the lookup set produced by unqualified lookup (3.4.1) and let Y be
the lookup set produced by argument dependent lookup (defined as follows). If
X contains
- a declaration of a class member, or
- a block-scope function declaration that is not a using-declaration, or
- a declaration that is neither a function or a function template
then
|
9/5/2010 7:34:45 PM
|
2
|
"Johannes Schaub (litb)" <schaub-johan...@web.de>
|
Fast way to add null after each char
std::string s = "easy";
std::string unicode_string;
std::string::const_iterator it,
for(it = s.begin(); it != s.end(); ++it)
{
unicode_string.push_back(*it);
unicode_string.push_back('\0');
}
The above for loop would make unicode_string look like this:
"e null a null s null y null"
Is there a faster way to do this... in place maybe?
Thanks for any tips,
Brad
|
9/5/2010 4:54:28 PM
|
28
|
Brad <byte8b...@gmail.com>
|
Boost function and bind issue
This code compiles:
boost::asio::ip::tcp::acceptor m_acceptor; // declared in a class
connector::pointer new_conn(new connector(m_acceptor.io_service()));
m_acceptor.async_accept
(
new_conn->socket(),
boost::bind
(
&timingserver::handle_accept,
this,
boost::asio::placeholders::error,
new_conn
)
);
So now I want to pull out the boost::bind part and make a function object of it.
boost::function
<
void
(
const boost::system::error_code &,
boost::asio::ip::tcp
|
9/5/2010 3:48:31 PM
|
7
|
Chris Ahlstrom <ahlst...@xzoozy.com>
|
iterator_traits and SFINAE
Hello,
the standard defines iterator_traits with:
namespace std {
template<class Iterator> struct iterator_traits {
typedef typename Iterator::difference_type difference_type;
typedef typename Iterator::value_type value_type;
typedef typename Iterator::pointer pointer;
typedef typename Iterator::reference reference;
typedef typename Iterator::iterator_category iterator_category;
};
}
plus two partial specializations for pointers.
Since the typedefs are always present, iterator_traits can't be
instantiated with a non-iterator template argument, and
|
9/5/2010 1:28:15 PM
|
3
|
Marc <marc.gli...@gmail.com>
|
What's the "%02X" specifier doing?
Hi,
----------code----
int main(){
char Md5Str[34] = "670B14728AD9902AECBA32E22FA4F6BDx";
char Md5Value[1];
sscanf(Md5Str, "%02X", &Md5Value[0]);
}
--------------------
It gives me "run-time check failure #2 stack around the variable was
corrupted" error.
But I expected the Md5Value array is large enough to hold the only
value I interested in.
I searched the Internet and someone says that sscanf will append a
'\0' character in the end, so Md5Value size should be at least two.
But I still got error until Md5Value size is as large as 4. Also no
error suggested for the follo
|
9/5/2010 5:25:35 AM
|
2
|
thomas <freshtho...@gmail.com>
|
Identifying a single template specialization
The desired outcome of the following is that it works (latest draft, n3126)
template<typename T> void f() { }
template<typename T> void g(T) { }
int main() { g(&f<int>); }
But I see a problem with that: When is the "&f" inspected in the gist of
14.8.1/3? We can have several places where we could apply it:
- Before argument dependent lookup is done. This would possibly affect
result of argument dependent lookup, because it might add associated classes
(if the function type of the specialization contains those classes).
- Before template argument deduction for the set of t
|
9/4/2010 12:28:06 PM
|
4
|
"Johannes Schaub (litb)" <schaub-johan...@web.de>
|
historical data from many sources: design questions
Hello,
I have measurements done daily (work days) for the past 20 years or so, in
the order then of 5000 or so entries.
I currently have them in a text file (I've hand written the parser but I'll
move to boost::spirit eventually)
The application is growing:
.. I may move to 20 years worth of measures every few seconds and arrive at a
range of 50 000 000 entries. Each entry is probably 64 bytes.
.. I may use a database
.. I may receive the data over a network socket
I have a class 'historical_data' that currently holds the 5000 in memory. A
standalone function (in the same
|
9/4/2010 4:30:37 AM
|
4
|
"Hicham Mouline" <hic...@mouline.org>
|
Writing binary data from database to file
Hello everybody out there using C++,
My C++ program should retrieve binary data from a database and write it
to a file. It looks like this:
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include "libpq-fe.h"
using namespace std;
int main(void)
{
PGconn *conn;
PGresult *res;
conn = PQconnectdb("hostaddr='my.remote.host' port='5432'
dbname='my_db' user='user' password='secret' connect_timeout='9'");
if (PQstatus(conn) != CONNECTION_OK)
{
fprintf(stderr, "Connection to database failed: %s",
PQerrorM
|
9/3/2010 10:55:22 PM
|
2
|
Julia Jacobson <julia.jacob...@arcor.de>
|
Are additional constructors for standard containers allowed?
With MSVC 10.0
std::bitset<32>( 666u )
does not compile. Apparently due to an extra constructor taking 'int' argument.
Is that allowed by the standard?
Cheers,
- Alf
--
blog at <url: http://alfps.wordpress.com>
|
9/3/2010 11:37:48 AM
|
27
|
"Alf P. Steinbach /Usenet" <alf.p.steinbach+use...@gmail.com>
|
UB while dealing with invalid raw pointers, the std::uninitialized_fill case
Hi there,
as far as I've been able to understand, if a raw pointer contains an
invalid value (that is, it does not point to any valid object of the
type it is a pointer to) then some of the actions performed on these
pointers will lead to UB.
As it seems, two actions in particular should be safe and well defined:
- zeroing the invalid pointer;
- assigning a valid value to the invalid pointer;
One issue that has been recently raised in this group is about storing
invalid raw pointers into a container such as std::vector; the rationale
that led to define it as a potential sour
|
9/3/2010 10:52:12 AM
|
13
|
"Francesco S. Carta" <entul...@gmail.com>
|
"partial" iterator?
Hello,
I have a std::map<std::string, boost::shared_ptr<my_type_t>>.
I often lookup based on the key (std::string)
I have a use case where I want to iterate over all the map except for keys
that begin with "RF".
I could iterate and check if iterator->first.find("RF")==0, then ignore it.
typedef std::map<std::string, boost::shared_ptr<my_type_t>> my_container_t;
my_container_t my_container;
for (my_container_t::const_iterator i=my_container.begin();
i!=my_container.end(); ++i)
if (i->first.first.find("RF")!=0)
//proceed
Is there a better way ? perhaps a smar
|
9/3/2010 2:39:20 AM
|
4
|
"Hicham Mouline" <hic...@mouline.org>
|
simple boost::test, undefined reference to main
Hi,
the following code does not compile and being a newbie, i am unable to
figure it out. could you please help?
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
int add( int i, int j ) { return i+j; }
BOOST_AUTO_TEST_CASE( my_test ){
BOOST_CHECK( add( 2,2 ) == 4 );
}
compiled with the command, g++ test.cpp -lboost_unit_test_framework
Error: undefined reference to `main'
thanks
suresh
|
9/2/2010 9:32:18 PM
|
7
|
suresh <suresh.amritap...@gmail.com>
|
Use Cases for Concurrent Data Structures
Libraries of data structures designed to support concurrent operations and to
scale well with the number of threads are common, e.g., ConcurrentHashMap and
ConcurrentLinkedQueue in Java, ConcurrentQueue and ConcurrentBag in .NET,
concurrent_queue and concurrent_vector in TBB and PPL. If the comments in a
recent thread in comp.lang.c++ ( http://tinyurl.com/2ey8mta ) are
representative, however, there is considerable skepticism that such data
structures are useful and some concern that designs employing them are almost
certainly misguided. Considerable googling on my part has fai
|
9/2/2010 7:37:21 PM
|
1
|
Scott Meyers <NeverR...@aristeia.com>
|
can I use stl vector iterator to delete a vector of pointers?
hi, there,
Assume I have a vector of points vector<obj*> v and I need to free the
memory.
More over, some of the element in v are already deleted (null
pointer).
Is it ok if I do like this:
for (vector<Obj*>::iterator it(v.begin()), ite(v.end()); it!= ite; +
+it{
if (*it != 0){
delete *it;
}
}
Thanks a lot.
zl2k
|
9/2/2010 6:48:41 PM
|
23
|
zl2k <kdsfin...@gmail.com>
|
Using "setlocate()" to get the language
Hello,
I'm writing some cross-platform software in C++, within it I have a
list of strings for various languages - My problem now is, how do I
determine the language setting of the person running the code so I can
present them information in the correct language? I'd rather not have
to resort to an entire framework just for this small function.
I tried "setlocale()" which always returns "C" on my Debian Lenny test
machine. I don't mind having slightly different functions for each OS
(I believe there are functions in the Windows API to determine
language, so that's taken care of)
|
9/2/2010 4:16:46 PM
|
8
|
CodHubIV <codhu...@gmail.com>
|
partial specialzation of a member function
Hello,
I have a template like below :
template<class T, class U> struct X
{
void f();
};
I want a partial specialization as :
template <class T>
void X<T, char>::f() { cout << "Partial specialization 1" << endl; }
It doesnt work. My Visual studio 2008 compiler says :
error C3860: template argument list following class template name must
list parameters in the order used in template parameter list
error C2976: 'X<T,U>' : too few template arguments
Any help please?
Thanks
|
9/2/2010 2:11:52 PM
|
2
|
"pers...@googlemail.com" <pers...@googlemail.com>
|
operator++ execution order differs between scalar types and classes
Hi,
Can anyone explain please why gcc (and possibly other compilers too)
treats scalar types and classes differently in terms of the order in
which their operator++ is executed?
For example, the following code:
int x(0), y(0);
y = x++ + x++;
printf("x=%d y=%d\n", x, y);
yields output:
x=2 y=0
as if the code had been:
int x(0), y(0);
y = x + x;
x++;
x++;
printf("x=%d y=%d\n", x, y);
On the other hand, if I replace 'int' with a class that has all
relevant ctors and operators (including operator++) defined:
MyIntClass x(0), y(0);
y = x++ + x++;
printf("x=%d y
|
9/2/2010 12:55:46 PM
|
2
|
Zeguudo Zegudissimo <zegu...@gmail.com>
|
[OT/2] Curiosity about inlining member functions
Hi there,
just wondering... what are the chances of a compiler to inline a member
function in a case like this:
struct A {
void method() {
helper();
}
void helper() {
//...
}
};
The definition of helper() is not available where it's being used, would
that mean that the compiler will not be able to inline it?
Is the compiler allowed to "rewrite" the above as something like this:
struct A {
void helper() {
//...
}
void method() {
helper();
}
};
In order to take advantage of inlineing?
And finally, does it change any
|
9/2/2010 11:57:00 AM
|
5
|
"Francesco S. Carta" <entul...@gmail.com>
|
does map find guarantee to not copy mapped value?
Hello,
I find myself writing a lot of code like the one below where I find
something out of a map and then use a reference to second to
interrogate the mapped object:
#include <iostream>
#include <map>
class Expensive { /* lots of stuff here... */ };
int main()
{
std::map<int,Expensive> m;
m.insert(std::make_pair(1,Expensive(3)));
// and then later
std::map<int,Expensive>::const_iterator it = m.find(1);
const Expensive& expensive = (*it).second;
// use expensive here - is this safe?
}
Is this practice safe? I've just determined on VC9 compiler that the
|
9/2/2010 10:03:06 AM
|
2
|
PeteUK <newbar...@gmail.com>
|
Dependency Injection vs. Global/Static data
Hi,
----injection---
class Util{
public:
void print(){...}
};
class Work{
void SetUtil(Util* pUtil){m_pUtil = pUtil;}
Util* m_pUtil;
};
----end----
----static----
class Util{
public:
static void print(){...}
};
----------
What's the advantages/disadvantages when comparing these two methods?
When I use these two methods in dll interface(Work class inside dll;
Util may be used by several modules.), anything I need to take special
care of?
|
9/2/2010 8:14:46 AM
|
4
|
thomas <freshtho...@gmail.com>
|
complexity of trigonometric functions
Hello,
I have a piece of code that I am trying to optimize. It is nothing
special - just some calculations, including trigonometric functions
(bunch of multiplications with sin and cos here and there). My code
duplicates in some places, but that is ok.
The questions are :
How complex are sin and cos functions? Are they simple look up tables?
Or are they some super-complex calculations.
If translated to multiplication/addition, how many
multiplications/additions would one sin or cos involve?
I am well aware this is implementation dependant, but it is probably
done in very
|
9/2/2010 8:22:07 AM
|
21
|
Vladimir Jovic <vladasp...@gmail.com>
|
raynor
raynor! this is test word!
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
|
9/2/2010 5:53:35 AM
|
0
|
raynor <raynor....@gmail.com>
|
How to initialise member variable in template construction
I am trying to set the strategy (algorithm) used in a context by
template. Here is my context class (which is incorrectly
implemented):
template <class TStrategy>
class Context //TStrategy is the algorithm
{
private:
TStrategy * strategy_; //knows about StrategyInterface
public:
void execute() const
{
strategy_->execute();
}
};
The strategies:
class StrategyInterface
{
public:
virtual void execute() const = 0; //abstract class - interface
only
};
//the actual concrete algorithms
class ConcreteStrategy
|
9/1/2010 9:43:29 PM
|
0
|
Angus <anguscom...@gmail.com>
|
Problems with the moderated newsgroup
To all concerned,
There are some technical problems we're experiencing with the
moderation server for 'comp.lang.c++.moderated', which caused
temporary suspension of processing of articles. If you posted
recently and are still awaiting for your post to appear, it is
due to that reason, most likely.
No ETA, unfortunately. In the mean time you might want to post
your question here instead, many folks read both newsgroups.
With apologies,
V
--
I do not respond to top-posted replies, please don't ask
|
9/1/2010 7:24:52 PM
|
1
|
Victor Bazarov <v.baza...@comcast.invalid>
|
Variables in "for" Loop
Hi,
Why does
for (list<string> newlines = frame(oldlines),
list<string>::iterator line = newlines.begin();
line != newlines.end();
++line)
not work, while
list<string> newlines = frame(oldlines);
for (list<string>::iterator line = newlines.begin();
line != newlines.end();
++line)
does?
Regards.
|
9/1/2010 7:31:15 PM
|
8
|
Volkan YAZICI <volkan.yaz...@gmail.com>
|
Concurrent Containers
Although C++0x includes support for concurrency, it offers no standard
containers that support simultaneous readers and writers. Java and .NET
developers have them as part of their standard libraries (e.g., Java's
Concurrent HashMap and ConcurrentLinkedQueue, .NET's ConcurrentQueue and
ConcurrentBag), but, from what I can tell, there don't even seem to be any de
facto standard concurrent containers for C++ developers. For example, Boost
doesn't seem to offer any.
The closest thing I can find to a portable cross-platform API for concurrent
containers are concurrent_vector and
|
9/1/2010 6:01:47 PM
|
50
|
Scott Meyers <NeverR...@aristeia.com>
|
Design Problem 2
Hi.
I have another design problem. I hope someone can help me. Thanks in
advance.
I want to write a "library" consisting in a bunch of objects like
Info, Utils, etc..
I made a member with each of these inside de main class (the
"library") and made the constructors private for Info, Utils, etc. and
made them friend classes of the main class.
Is this the right approach or should I use heritance from a base
class? I also need to access some of the methods in Utils from Info,
for instance, Format date function, trims, etc. etc. meaning that
utils will be accessible from outside th
|
9/1/2010 5:41:09 PM
|
3
|
jp <juanpolo...@hotmail.com>
|
Why I cannot call public non-virtual member function of DLL?
Hi,
Hmm. seems a little silly..
Here comes the puzzle.
-----dll------------
class TestAdd
{
public:
void TestNormal();
virtual void TestVirtual();
}
extern "C" TestAdd* TestAddCreate(){
return new(std::nothrow) TestAdd();
}
------------------
Above is part of the dll class. The implementation part is missed
deliberately.
TestAdd* instance = TestAddCreate();
When I call "instance->TestNormal()", it says
------message-----
error LNK2019: unresolved external symbol "public: void __thiscall
TestAdd::TestNormal(void)" (?TestNormal@TestAdd@@QAEXXZ) ref
|
9/1/2010 8:30:31 AM
|
10
|
thomas <freshtho...@gmail.com>
|
std vector iterator optimization question
hi, there,
---------code 1-------------
for (vector<int>::interator it = somevector.begin(); it !=
somevector.end(); it++){...}
---------code 2-------------
vector<int>::iterator stop = somevector.end();
for (vector<int>::interator it = somevector.begin(); it != stop; it++)
{...}
Question:
If the somevector's length does not change, is code2 a better
implementation than code1 (since it saves the end() call for each
loop)?
For const_iterator, does stl already do the optimization so that code1
and code2 won't have much difference?
Thanks a lot.
zl2k
|
9/1/2010 4:27:19 AM
|
13
|
zl2k <kdsfin...@gmail.com>
|
Is there any problem with customizing a new interface out of other interfaces?
Hi,
Let's say I have three interfaces
class IWorker
{
public:
virtual ~IWorker() {}
virtual void work() = 0;
};
class IEnergyConsumer
{
public:
virtual ~IEnergyConsumer() {}
virtual void refuel( int energy ) = 0;
};
class ICloner
{
public:
virtual ~ICloner() {}
virtual ICloner* clone() = 0;
};
Would it be problematic or immoral to create a new pure interface out of
those, like this?
class ICell : public IWorker, public IEnergyConsumer, public ICloner
{
public:
virtual ~ICell() {}
};
Or is it just fine to customize ne
|
8/31/2010 7:31:37 PM
|
8
|
DeMarcus <use_my_alias_h...@hotmail.com>
|
simple question about typedefs....
extern DNSServiceCreateConnection(DNSServiceRef *sdRef);
typedef struct _DNSServiceRef_t *DNSServiceRef;
This statement creates a type called DNSServiceRef, which is a pointer
to a structure???
But I have no idea what a _DNSServiceRef_t is...
DNSServiceRef r; // Is just an uninitialized pointer?
Am I correct in assuming that there is NO such structure as a
_DNSServiceRef_t or that it is meant to be 'opaque' to me?
I'm asking because I'm trying to port this c/c++ code into another
language and I need to be sure I understand the data types being
passed....
_DNSServiceRef
|
8/31/2010 6:31:45 PM
|
3
|
SpreadTooThin <bjobrie...@gmail.com>
|
Poll: Which type would you prefer for UTF-8 string literals in C++0x
Hi!
This is a poll to get *short* opinions on the planned literal type for
the UTF-8 string literals in C++0x. (Please, no Unicode lectures ;-)
The current draft for C++0x specifies for UTF-8 string literals:
( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3126.pdf )
[N3126, p28, �2.14.5]
[Item 6] A string literal that begins with u8, such as u8"asdf",
is a UTF-8 string literal [...]
[Item 7] Ordinary string literals and UTF-8 string literals are
also referred to as narrow string literals. A narrow
string literal has type "
|
8/31/2010 3:35:48 PM
|
15
|
"Martin B." <0xCDCDC...@gmx.at>
|
How to tell if an exception has currently been thrown and is being processed ?
Hello
What is the function that could tell if there is an exception currently
being thrown, that is causing stack unwinding ? I guess it was a
function returning true during unwinding and false otherwise.
Also, is there a way to get the current exception object (other then as
the argument to the catch handler) ?
Is there a way to store or keep the exception object (and its type) for
later processing outside of the handler or the try-catch function that
caught it ?
Thank you,
Timothy Madden
|
8/31/2010 12:34:41 PM
|
7
|
Timothy Madden <terminato...@gmail.com>
|