Use C ++ class in objective-c

Basically, I have two source files, for example, the following in my workspace:

vectormath_aos.h

#ifndef _VECTORMATH_AOS_CPP_SCALAR_H
#define _VECTORMATH_AOS_CPP_SCALAR_H

#include <math.h>

#ifdef _VECTORMATH_DEBUG
#include <stdio.h>
#endif

namespace Vectormath {

namespace Aos {

//-----------------------------------------------------------------------------
// Forward Declarations
//

class Vector3;
class Vector4;
class Point3;
class Quat;
class Matrix3;
class Matrix4;
class Transform3;
...

exampleopenglesViewController.mm

#import <QuartzCore/QuartzCore.h>

#import "exampleopenglesViewController.h"
#import "EAGLView.h"
#import "vectormath_aos.h"

Matrix4 mvpmatrix;
...

However, when I try to start a project in Xcode 4.0, it always gives me an error: An unknown name like "Matrix4". I am really confused because it worked for me when I was working on Xcode 3.2. Does anyone know what's wrong here? Thanks in advance!:)

+3
source share
1 answer

Since you are using namespaces,

Matrix4 mvpmatrix;

it should be:

Vectormath::Aos::Matrix4 mvpmatrix;

instead.

+4
source

All Articles