Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem in returning the used defined data type using structure

Problem in returning the used defined data type using structure

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphics
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Manoj7390
    wrote on last edited by
    #1

    hi everyone.. I have written a program where I want to return three user defined data types to the another main() function (here i have not mentioned that main). I want to return {Pa,c1,c2} from this program. Please help me out.

    #include <cstdlib>
    #include <iostream>
    #include <vector>
    using std:: cout;
    using std:: cin;
    using std:: endl;
    using namespace std;
    #include <math.h>
    #include "FiniteFieldElement.hpp"

    namespace Cryptography
    {
    template<int P>
    class EllipticCurve
    {
    public:

                typedef FiniteFieldElement<P> ffe\_t;
                 
                class   Point
                {
                    friend  class   EllipticCurve<P>;
                    typedef FiniteFieldElement<P> ffe\_t;
                    ffe\_t  x\_;
                    ffe\_t  y\_;
                    EllipticCurve    \*ec\_;
                    
                    void   addDouble(int m, Point& acc)
                    {        
                        if ( m > 0 )
                        {       
                            Point r = acc; 
                            for ( int n=0; n < m; ++n )
                            {
                                r += r;     // doubling step                          
                            }
                            acc = r;
                        }        
                    }
                    
                    Point scalarMultiply(int k, const Point& a)
                    {
                        Point acc = a;
                        Point res = Point(0,0,\*ec\_);
                        int i = 0, j = 0;
                        int b = k;
                        
                        while( b )
                        {
                            if ( b & 1 )
                            {
                                addDouble(i-j,acc);
                                res += acc;           
                                j = i;  
                            }
                            b >>= 1;
                            ++i;
                        }
                        return res;
                    }
                    
                    void    add(ffe\_t x1, ffe\_t y1, ffe\_t x2, ffe\_t y2, ffe\_t & xR, ffe\_t & yR) const
                    {
                                              
                        if ( x1 == 0 && y
    
    L 1 Reply Last reply
    0
    • M Manoj7390

      hi everyone.. I have written a program where I want to return three user defined data types to the another main() function (here i have not mentioned that main). I want to return {Pa,c1,c2} from this program. Please help me out.

      #include <cstdlib>
      #include <iostream>
      #include <vector>
      using std:: cout;
      using std:: cin;
      using std:: endl;
      using namespace std;
      #include <math.h>
      #include "FiniteFieldElement.hpp"

      namespace Cryptography
      {
      template<int P>
      class EllipticCurve
      {
      public:

                  typedef FiniteFieldElement<P> ffe\_t;
                   
                  class   Point
                  {
                      friend  class   EllipticCurve<P>;
                      typedef FiniteFieldElement<P> ffe\_t;
                      ffe\_t  x\_;
                      ffe\_t  y\_;
                      EllipticCurve    \*ec\_;
                      
                      void   addDouble(int m, Point& acc)
                      {        
                          if ( m > 0 )
                          {       
                              Point r = acc; 
                              for ( int n=0; n < m; ++n )
                              {
                                  r += r;     // doubling step                          
                              }
                              acc = r;
                          }        
                      }
                      
                      Point scalarMultiply(int k, const Point& a)
                      {
                          Point acc = a;
                          Point res = Point(0,0,\*ec\_);
                          int i = 0, j = 0;
                          int b = k;
                          
                          while( b )
                          {
                              if ( b & 1 )
                              {
                                  addDouble(i-j,acc);
                                  res += acc;           
                                  j = i;  
                              }
                              b >>= 1;
                              ++i;
                          }
                          return res;
                      }
                      
                      void    add(ffe\_t x1, ffe\_t y1, ffe\_t x2, ffe\_t y2, ffe\_t & xR, ffe\_t & yR) const
                      {
                                                
                          if ( x1 == 0 && y
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Return it to where, and where and what are these variables? Please also delete your duplicate of this post.

      Use the best guess

      S 1 Reply Last reply
      0
      • L Lost User

        Return it to where, and where and what are these variables? Please also delete your duplicate of this post.

        Use the best guess

        S Offline
        S Offline
        Stefan_Lang
        wrote on last edited by
        #3

        Both threads are copies from here

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups