Using C ++ Structures with iPhone Application

As I heard, in the iPhone project (Objective-C) you can use C ++ code, I want to use an encryption library written in C ++. However, the library uses a C ++ type structure that uses a constructor that I cannot get correctly.

The design is as follows:

struct SBlock
{
 //Constructors
 SBlock(unsigned int l=0, unsigned int r=0) : m_uil(l), m_uir(r) {}
 //Copy Constructor
 SBlock(const SBlock& roBlock) : m_uil(roBlock.m_uil), m_uir(roBlock.m_uir) {}
 SBlock& operator^=(SBlock& b) { m_uil ^= b.m_uil; m_uir ^= b.m_uir; return *this; }
 unsigned int m_uil, m_uir;
};

full source is available here: http://www.codeproject.com/KB/security/blowfish.aspx

What is the easiest way to get around this? I read an article about using C ++ code on the Apple developer website, but that didn't help much.

+3
source share
2 answers

, : ++ Objective-C ++, .mm .m.

, YourViewController.h YourViewController.m, YourViewController.mm. XCODE ++ C Objective-C ++.

YourViewController.mm:

- (void) yourMessage {
    // will compile just fine and call the appropriate C++ constructor
    SBlock sb(1,1); 
}
+6

.m .mm ++. , , lol.

+3

Source: https://habr.com/ru/post/1779454/


All Articles