Thanks a lot, I will study Objective-C Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides) and
Beginning Mac Programming: Develop with Objective-C and Cocoa.

Once you've learned Objective-C, you'll know how to use Objective-C++.

This is the reason why the books of objective C++ are hard to find ?Because it is unneccessary?

Thanks, but I have studied C++ before(even now I am still studying C++), I know the concepts of OOP, GP, TMP,
STL and procedural programming, although I am not an expert of C++ yet, but I think I am good enough to handle
daily programming with C++(and I like C++).

I need a book which could talk about objective C++ but not objective C, there are tons of books introduce objective C
but none(?) of it cover the details of objective C++?

I found a lot of books introduce about objective C but can't find a book which talk about objective C++.Could you introduce me an objective C++ textbook?
I learned C++ before but don't know objective C, where should I start if I want to learn objective C++?Looks like it is a superset of C++?Could it co-work
with some of the features of C++11?

Thank you very much

template<typename View>
struct pixel_traits;

template<>
struct pixel_traits<gray8c_view_t>
{
  typedef gray8c_pixel_t type;
}

Could I find something like this from gil?Thanks

Sorry, I solved the problem by myself
I forgot to measure the value of src(x - 1, y) and src(x + 1, y)
GIL makes the manipulation of pixels become much more easier
Thanks

Sorry, I find out the problem, I misplaced height and width
besides, the dst should be boost::gil::gray8_view_t

I solve the problem of segmentation fault
yet the dst image is pretty weird(only white and black)

template<typename T = QWidget>
static std::unique_ptr<T> view_image_pair(QImage const &src, QImage &dst)
{
    std::unique_ptr<T> window(new T);
    QHBoxLayout *layout = new QHBoxLayout(window.get());

    QLabel *src_label;
    layout->addWidget(src_label = new QLabel);
    src_label->setPixmap(QPixmap::fromImage(src));

    QLabel *dst_label;
    layout->addWidget(dst_label = new QLabel);
    dst_label->setPixmap(QPixmap::fromImage(dst));

    return std::move(window);
}

static void read_image(QApplication &a)
{    
    QImage src("../GIL_with_Qt/images_00/coneL.bmp");
    QImage dst(src.size(), src.format());

    std::unique_ptr<QWidget> window = view_image_pair(src, dst);
    x_gradient_qt(src, dst);

    window->show();

    a.exec();
}

What kind of mistakes I make this time?Thanks

#ifndef EXAMPLE_HPP
#define EXAMPLE_HPP

#include <memory>

#include <boost/gil/gil_all.hpp>

#include <QtGui/QApplication>
#include <QtGui/QHBoxLayout>
#include <QtGui/QImage>
#include <QtGui/QLabel>
#include <QtGui/QWidget>

//#include "image_details.hpp"

static void x_gradient(boost::gil::gray8c_view_t const &src, boost::gil::gray8s_view_t const &dst)
{
    for (int y = 0; y != src.height(); ++y)
        for (int x = 1; x != src.width() - 1; ++x)
            dst(x, y) = (src(x - 1, y) - src(x + 1, y)) / 2;
}

inline void ComputeXGradientGray8(unsigned char const *src_pixels, ptrdiff_t src_row_bytes,
                                  int w, int h, unsigned char *dst_pixels, ptrdiff_t dst_row_bytes)
{
    using namespace boost::gil;
    gray8c_view_t src = interleaved_view(w, h, (const gray8_pixel_t*)src_pixels, src_row_bytes);
    gray8s_view_t dst = interleaved_view(w, h, (     gray8s_pixel_t*)dst_pixels, dst_row_bytes);

    x_gradient(src, dst);
}

static inline void x_gradient_qt(QImage const &src, QImage &dst)
{
    ComputeXGradientGray8(src.bits(), src.bytesPerLine(), src.height(),
                          src.width(), dst.bits(), dst.bytesPerLine());
}        

static void read_image()
{    
    QImage src("../GIL_with_Qt/images_00/coneL.bmp");
    QImage dst(src.width(), src.height(), src.format());

    x_gradient_qt(src, dst); //this will cause segmentation fault                      
}

#endif // EXAMPLE_HPP

depth : 8bit
format : QImage::Format_Indexed8
image width : 450
image height : 375
bytes per scan line : 452

How to integrate QImage with the example provided by the boost::gil?
This would cause segmentation fault yet I don't know why.
The algorithm seems nothing wrong
Thanks for your help

SpriteList.push_back(std::auto_ptr<Object>(new Object));

Sorry, I made a mistake

you could use smart pointer instead of the raw pointer

std::vector<std::auto_ptr<Object> > SpriteList;
SpriteList.push_back(new Object);

//if your compiler support unique_ptr, you could change auto_ptr to unique_ptr
//unique_ptr is a much more better choice than auto_ptr

like Scott Meyers said : "handle the resource by object"
Besides, according to exceptional c++ and more effective c++
if we don't handle the resource by object, it may bring us a lot of troubles

Recently I am studying GIL and concept(htp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2081.pdf)
and encounter a lot of problems.

concept ChannelConcept<typename T> : EqualityComparable<T> {
    typename value_type      = T;        // use channel_traits<T>::value_type to access it
       where ChannelValueConcept<value_type>; //tag1
    typename reference       = T&;       // use channel_traits<T>::reference to access it
    typename pointer         = T*;       // use channel_traits<T>::pointer to access it
    typename const_reference = const T&; // use channel_traits<T>::const_reference to access it
    typename const_pointer   = const T*; // use channel_traits<T>::const_pointer to access it
    static const bool is_mutable;        // use channel_traits<T>::is_mutable to access it

    static T min_value();                // use channel_traits<T>::min_value to access it
    static T max_value();                // use channel_traits<T>::min_value to access it
};

concept MutableChannelConcept<ChannelConcept T> : Swappable<T>, Assignable<T> {};

concept ChannelValueConcept<ChannelConcept T> : Regular<T> {}; //tag2

My questions about the codes are
1 :
concept ChannelValueConcept : Regular {};
According to the pdf(If I haven't made any mistakes), "ChannelConcept T" means "T" should be a model
of "ChannelConcept", plus the "Regular" means "T" should be a model of "ChannelConcept T" and
"Regular", do I make any mistakes?Thanks

2 :
tag1 and tag2 looks like some recursive concept?What is that mean?

3 :
According to the suggestion of the pdf, we should use nested concept rather than refinement in these cases?

Thank you very much

I don't know C# very well, but I know C, C++(primary language) and using java to develop some
app on android(even I don't like the philosophy of java, everything should be object?pointer is
too dangerous so we should not use it?you don't have to care about memory and so on).Before
I learn C++ and java, I always though they are almost equal to each other, C++ is just a "better c",
java is a safer and better C++.

The syntax of these languages are very similar to each other, but we can't simply say
"java is a next c++".If you have times, you will discover that these language are design
by different philosophy.

and arguably there are too many drawbacks to even consider C#/Java as better

After I study java, I find out that the abstaction mechanisms provided by java are not really
"much more powerful" than C++ as those companies propagate.An example is, java don't support generic programming as C++ do(no kidding, I don't think it is same as the generic of C++).
But the standard libs of java are very big, much more bigger than the libs of C++11, you don't
need to find libs A or libs B when you are using java like C++, maybe the biggest weakness
of C++ is the skinny standard libs.

This made C++ a multi-paradigm programming language that seeminglessly mixes functional, object-oriented, generic, and meta- programming paradigms natively

I like generic programming and the thing meta-programming could do, but ...

Thank you very much, I will survey GIL from now, hope someday I could contribute some of
my efforts onto the website(if my codes are good enough to be accepted).

This is yet another installment of the everyday dilemma between a well-designed, generic but feature-deprived library, and a feature-rich but messy librar

It is reasonable, good codes like STL are valuable but it is very expensive
Besides, there are only a few of people who have the ability to develop this kind
of library(I would be very happy if I have that kind of skills) and maintain
it.What your boss want is "money", as long as the codes work, no one care about
it is well design or poor design.

I believe that it is too hard to ask most of the commercial companies to develop
good codes, but they could develop something "just work", "high efficiency" yet
extremely messy.No comments, inconsistent interfaces, different naming rules,
anti patterns(maybe a good solution in other languages, but sometimes your boss may ask
you to study a brand new language and hand out the project on next week,
I believe that how to design a good program and how to design a good program by specific
are not totally the same, each of them have different philosophy and abstraction mechanism.
But if programmers are running out of time, they have no choice but to treat apple as orange
even it is apple) and so on.

I would like to study the source codes of openCV and reimplement them by
the boost generic image library, I hope the algorithms developed by GIL
could be integrated with Qt seamlessly.

There are many libraries of image processing and I don't need to implement
them again if I only want to develop some app, I would like to do this because
I want to learn something from surveying the source codes of openCV(looks like
this is a well design library) and the generic image library.

I haven't studied GIL yet, anybody who studied GIL could give me some advices?
Thanks a lot.

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines

class Wizard : public QDialog
{
  Q_OBJECT

  public:
    Wizard(QWidget *parent);

    private slots:
    void what_ever();

    private:
    QPushButton *what_ever;  
};

Wizard::Wizard( QWidget *parent ) : QDialog(parent)
{  
  QGridLayout *layout = new QGridLayout( this );

  QScopedPointer<QTextEdit> textEdit(new QTextEdit); 
  layout->addWidget( textEdit.take(), 0, 0, 1, 2 );

  what_ever = new QPushButton("whatever");
  layout->addWidget(what_ever, 0, 1, 1, 1);

  connect(what_ever, SIGNAL(clicked()), this, SLOT(what_ever()));
}

void Wizard::what_ever()
{
  //blah blah blah
}

I have some problems about the codes.

1 : What if textEdit throw exception?
If "textEdit" throw exception, that means the
destructor of Wizard would not be called,
What would Qt handle the resource of "layout"?

2 : Could I initialize "what_ever" like this?
layout->addWidget(what_ever = new QPushButton("whatever"), 0, 1, 1, 1);
Is this safe in Qt4(4.8)?Would it have any change to cause memory leak?

Thanks a lot

1 : use 3rd libraries, ex : openCV, CImg
2 : study the format of pgm and encode by yourself

example of openCV

#include<opencv2\core\core.hpp>
#include<opencv2\highgui\highgui.hpp>

int main()
{
  cv::Mat img = cv::imread("lena.pgm", -1);
  cv::imshow("output image", img);

  cv::waitKey();

  return 0;
}

[quote] I want to create function that moves chars for one spot, for example a -> b, b -> d ... is it possible to do that without an array?[/quote]
yes, you could do it by list, deque or hash table, but array would be the best choice
in most of the cases.

[QUOTE=;][/QUOTE]
Thanks, I will take a look on it.

I don't really get your question
you could save all of the string into a vector rather
than save them into an old style array
Then iterate through all of the string in the vector

[code]
//don't pass by value but pass by reference
//remember to add const if you don't want the str to be changed
int numS( string str )
{
int countChar = 0;

for (int i = 0; str[i] != '\0'; i++)
{
    if ( str[i] == 's' )
        countChar++;
}

return countChar;

}
[/code]

you could make your life easier by template
[code]
template
size_t num( std::string const &str )
{
int countChar = 0;

for (int i = 0; str[i] != '\0'; i++)
{
    if ( str[i] == ch )
        countChar++;
}

return countChar;

}

typedef num<'z'> numZ;
typedef num<'s'> numS;
typedef num<'c'> numC;
[/code]

I don't know why are you want to design something like numA, numZ and so on
would it better than countChar?

[quote]I have to count how many c,s,z are there in that array. I did it like this and i can't figure it out... Thanks again for help...[/quote]
you mean your countChar has some problem?
Your logics looks good for me, but you have to pass the std::string like this
[code]
size_t countChar( vrstica.c_str() , 's' );
[/code]

and change the interface to
[code]
size_t countChar( char const *str , char ch );
[/code]

besides, you don't need to pass the string by array and write a for loop
you could just do it like this
[code]
void reverseString(string const &a)
{
string rstr = a;
reverse(rstr.begin(), rstr.end());
cout << rstr << endl;
}
[/code]

There are many ways to do the same job, you could try another solutions if you like
example : make the codes become shorter and save a temporary variable i
[code]
size_t countChar( char const *str , char ch )
{
size_t countChar = 0;

//generally speaking, postfix++ is not a good idea, but it
//is ok for primitive types like char
while(*str) if(*str++ == ch) countChar += 1;          

return countChar;

}
[/code]

you could solve this problem by stl too
[code]
template
size_t countChar( ForwardItr begin , ForwardItr end, char ch)
{
size_t sum = 0;
std::for_each(begin, end, [&](char fir){ if(fir == ch) ++sum;} );

return sum;
}
[/code]

Your codes are not bad, but there are still something could be refine
[code]
//this is not initialize but assignment
Player::Player(int MyID, string MyFactionName) {
ID=MyID;
FactionName=MyFactionName;
}
[/code]

[code]
//This is initialize
Player::Player(int MyID, string MyFactionName) :ID(MyID), FactionName(MyFactionName){ }
[/code]

[code]
//you are intent to copy the string, use std::string const& instead of string
//if you want to construct MyFactionName directly, it is another story
Player::Player(int MyID, string MyFactionName) {
ID=MyID;
FactionName=MyFactionName;
}
[/code]

[code]
//you could save the size into another variable
//size_t Size = MyUnits.size();
//use size_t rather than unsigned int, it would be easier to shift to 64bits
//use prefix++ rather than postfix++
//use != rather than < if you want to cope with generic programming
for(size_t i=0; i != Size; ++i) {
[/code]

just some opinions of coding style, another problems like protected or the name
like a, b, c, d, e.Better don't do these in a big project or when you need to
cooperate with other.

If my comments have any mistakes, please feel free to critics me.Thanks

Thanks, I will take a look at Comeau.

another solution
[code]

include
include
include
include

template
void reverseString(ForwardItr begin, ForwardItr end)
{
while(begin != end)
{
std::reverse(begin->begin(), begin->end());
++begin;
}
}

int main()
{
std::string value[] = {"one", "two", "three"};
enum {Size = sizeof(value)/ sizeof(*value)};
reverseString(value, value + Size);
std::copy(value, value + Size, std::ostream_iterator(std::cout,"\n"));
std::cin.get();

return 0;
}
[/code]

you could place your std::string into std::vector or std::list either
[code]

include
include
include
include
include

template
void reverseString(ForwardItr begin, ForwardItr end)
{
while(begin != end)
{
std::reverse(begin->begin(), begin->end());
++begin;
}
}

int main()
{
char const str[] = {"one", "two", "three"};
std::vector value(str, str + sizeof(str) / sizeof(
str) );
reverseString(value.begin(), value.end());
std::copy(value.begin(), value.end(), std::ostream_iterator(std::cout,"\n"));
std::cin.get();

return 0;
}
[/code]

Could I find some translator which could translate partial C++ codes
to equivalent C codes? like
[code]
int max(int A, int B);
double max(double B, double B);
[/code]

would be translate to something like
[code]
int maxInt(int A, int B);
double maxDouble(double B, double B);
[/code]

[code]
template<typename T = int, double, char>
T max(T A, T B);
[/code]

would be translate to something like
[code]
int maxInt(int A, int B);
double maxDouble(double B, double B);
char maxChar(char B, char B);
[/code]

Or I should write one for myself?
Ok, I know that I should use C++ if I like it
but I can't choose it by my free will
I have to design something like qsort if I have to use C
and it is what I am refuse to.That kind of codes are not
efficient at all but hard to debug and maintain.
But it is even harder to maintain if I don't design a
"partial generic" function by the way like that.

compile by vc2010, coding style of C++11?

[code]

include //for std::for_each, std::reverse and std::copy
include //for std::array
include //for std::cout, std::cin.get
include //for std::ostream_iterator
include

template
void reverseString(T &value)
{
std::for_each(value.begin(), value.end(),
[](std::string &fir)
{
std::reverse(fir.begin(), fir.end());
});
}

int main()
{
std::array<std::string, 3> value = {"one", "two", "three"};
reverseString(value);
std::copy(value.begin(), value.end(), std::ostream_iterator(std::cout,"\n"));
std::cin.get();

return 0;
}
[/code]

compile by vc2010, coding style of C++98?
[code]

include
include
include

//I don't know how to deduce the number of the element at compile time
//without passing a parameter "num", please tell me how to
//do it if you know, thanks
void reverseString(std::string value[], size_t num)
{
for(size_t i = 0; i != num; ++i)
std::reverse(value[i].begin(), value[i].end() );
}

int main()
{
std::string value[] = {"one", "two", "three"};
reverseString(value, sizeof(value)/ sizeof(*value) );
std::copy(value, value + 3, std::ostream_iterator(std::cout,"\n"));
std::cin.get();

return 0;
}
[/code]

the implementation of std::reverse are quite simple
I only post the one with random access iterator(a smart pointer which similar to pointer)

[code]
template
void Reverse(RandomItr begin, RandomItr end)
{
while(begin < end)
{
std::iter_swap(begin, --end);
++begin;
}
}
[/code]

Finally, i find out the reason
I should change the typedef of slist_iterator to
[code]
typedef Ref rereference;
typedef Ptr pointer;
[/code]
We really need three template parameters to tell the compiler
which one is const which one is not

I refine my codes of slist, please take a look on it.
[code]

ifndef NON_STL_SINGLY_LINK_LIST_HPP
define NON_STL_SINGLY_LINK_LIST_HPP
include
include
include"stl_construct.hpp"

struct slist_node_base
{
slist_node_base *next;
};

template
struct slist_node : public slist_node_base
{
T data;
};

struct slist_iterator_base
{
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;

slist_iterator_base(slist_node_base *x) : node(x) {}

bool operator==(slist_iterator_base const x) const { return node == x.node; }
bool operator!=(slist_iterator_base const x) const { return node != x.node; }

slist_node_base *node;

};

//three template parameters are designed to
//discern the const iterator and non-const iterator
template<typename T, typename Ref, typename Ptr>
struct slist_iterator : public slist_iterator_base
{
typedef slist_iterator<T, T&, T> iterator;
typedef slist_iterator<T, T const&, T const
> const_iterator;
typedef slist_iterator<T, Ref, Ptr> self;

typedef std::forward_iterator_tag iterator_tag;

typedef T              value_type;

typedef Ptr pointer;
typedef Ref reference;
typedef slist_node list_node;

slist_iterator(list_node *x) : slist_iterator_base(x) {}
slist_iterator() : slist_iterator_base(0) {}
slist_iterator(iterator const &x) : slist_iterator_base(x.node) {}

reference operator*() const { return static_cast<list_node*>(node)->data; }

pointer operator->() const { return &(operator()*); }

self& operator++()
{
    node = node->next;
    return *this;
}

self operator++(int)
{
    iterator temp = *this;
    ++*this;
    return temp;
}

};

inline slist_node_base slist_make_link(slist_node_base prev_node, slist_node_base *new_node)
{
new_node->next = prev_node->next;
prev_node->next = new_node;
return new_node;
}

size_t slist_size(slist_node_base *begin);

template<typename T, typename Alloc = ...

Oh man, I found another error from my codes
[code]
iterator& operator++(int)
[/code]
should not return&

sorry, after some test, const_iterator of my design didn't work
looks like I need three template parameters to solve it

Besides, we dont need
[code]
reference operator() { return static_cast<list_node>(node)->data; }
reference operator->() { return &(operator()*); }
[/code]

The source codes of stl_construct.hpp after some change

[code]

ifndef STL_CONSTRUCT_HPP
define STL_CONSTRUCT_HPP

/*

  • I use iterator_traits and type_traits provided by vc2010 to
  • do the same jobs as SGI STL did.I use SFINAE not because
  • "it is cool" but want to make the program become faster since passing
  • true_type or false_type may need to pass an one byte object but SFINAE
  • could save this one byte object. The draw back of this solution is, it
  • can't port to those old compilers which don't support type_traits or
  • SFINAE very well.
    */
include
include

template<typename T1, typename T2>
inline void construct_(T1 *p, T2 const &value)
{
new (p) T1(value);
}

template
inline void construct_(T1 *p)
{
new (p) T1();
}

/*

  • call destructor if T has no trivial destructor
    /
    template
    inline typename std::enable_if<!std::has_trivialdestructor::value>::type
    destroy
    (T
    p)
    { p->~T(); }

/*

  • do nothing if T has trivial destructor
    /
    template
    inline typename std::enable_if<std::has_trivialdestructor::value>::type
    destroy
    (T
    p)
    {}

/*

  • call destructor one by one if T has no trivial destructor
    */
    template
    typename std::enable_if
    <
    !std::has_trivial_destructor
    <
    typename std::iterator_traits::value_type

    ::value
    ::type
    destroy_(ForwardItr first, ForwardItr second)
    {
    for(; first != second; ++first) destroy(&*first);
    }

/*

  • do nothing if T has trivial destructor
    */
    template
    inline typename std::enable_if
    <
    std::has_trivial_destructor
    <
    typename std::iterator_traits::value_type

    ::value
    ::type
    destroy_(ForwardItr first, ForwardItr second)
    {}

endif

[/code]

The source codes of my naive slist
[code]

ifndef NON_STL_SINGLY_LINK_LIST_HPP
define NON_STL_SINGLY_LINK_LIST_HPP
include
include
include"stl_construct.hpp"

struct slist_node_base
{
slist_node_base ...

I am studying the source codes of SGI STL and have many problems with it.

I can't figure out the design choice of the iterator of SGI STL as follow
[code]

template <class _Tp, class _Ref, class _Ptr>
struct _Slist_iterator : public _Slist_iterator_base
{
typedef _Slist_iterator<_Tp, _Tp&, _Tp> iterator; #1
typedef _Slist_iterator<_Tp, const _Tp&, const _Tp
> const_iterator; #2
typedef _Slist_iterator<_Tp, _Ref, _Ptr> _Self; #3
};
[/code]

Why don't just change the _Slist_iterator to the way as #4 and #5
[code]
template
struct _Slist_iterator : public _Slist_iterator_base
{
typedef _Slist_iterator iterator; #4
typedef _Slist_iterator const iterator const_iterator; #5
};
[/code]

I mimic the slist of SGI STL and rewrite an simple version(for practice)
and change #1,#2,#3 to #4 and #5.The codes work, I don't what is the
reason to define the const_iterator and self like #2 and #3.

the source codes are a little bit long, I upload them to the link
[url]https://sites.google.com/site/noviceatc/important-documents/sgi_stl_practice_slist_00.rar?attredirects=0&d=1[/url]

The part of algorithms(except of sort) are pretty easy to cope up with,
but the containers part are pretty difficult for me.
Iterator is an important glue for STL, but I don't understand the design
choice of the iterator of SGI STL, could you tell me why ?Thanks.