Search Results

Search found 22308 results on 893 pages for 'floating point'.

Page 8/893 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • HTML background-size:cover with floating objects

    - by Mikhail
    I have a trivial page with body having an image background, with background-size:cover. I set html { height:100% } to fill up the entire page regardless of the content amount. Up to this point everything worked as expected. I've added a div and set position:absolute; right:0; width:200px; This, again, worked as expected, until I added content. When this div is populated so much that the contents take up more space than the height of the page, the scroll bar appears. Scrolling down reveals that the background image does not actually cover the entire page. This is due to the fact that my div is taller than 100% of the HTML height. How can I address this?

    Read the article

  • Does Guest WiFi on an Access Point make any sense?

    - by uos??
    I have a Belkin WiFi Router which offers a feature of a secondary Guest Access WiFi network. Of course, the idea is that the Guest network doesn't have access to the computers/devices on the main network. I also have a Comcast-issues Cable Modem/Router device with mutliple wired ports, but no WiFi-capabilities. I prefer to only run one router/DHCP/NAT instead of both the Comcast Router and the Belkin Router, so I can disable the Routing functions of the Belkin and allow the Comcast Router to But if I disable the Routing functions of the Belkin device, the Guest WiFi network is still available. Is this configuration just as secure as when the Belkin acts as a Router? I guess the question comes down to this: Do Guest WiFi's provide security by 1) only allowing requests to IPs found in-front of the device, or do they work by 2) disallowing requests to IPs on the same subnet? 1) Would mean that Guest WiFi on an access point provides no benefit 2) Would mean that the Guest WiFi functionality can work even if the device is just an access point. Or maybe something else entirely?

    Read the article

  • Does Guest WiFi on an Access Point make any sense? [migrated]

    - by Jason
    I have a Belkin WiFi Router which offers a feature of a secondary Guest Access WiFi network. Of course, the idea is that the Guest network doesn't have access to the computers/devices on the main network. I also have a Comcast-issues Cable Modem/Router device with mutliple wired ports, but no WiFi-capabilities. I prefer to only run one router/DHCP/NAT instead of both the Comcast Router and the Belkin Router, so I can disable the Routing functions of the Belkin and allow the Comcast Router to But if I disable the Routing functions of the Belkin device, the Guest WiFi network is still available. Is this configuration just as secure as when the Belkin acts as a Router? I guess the question comes down to this: Do Guest WiFi's provide security by 1) only allowing requests to IPs found in-front of the device, or do they work by 2) disallowing requests to IPs on the same subnet? 1) Would mean that Guest WiFi on an access point provides no benefit 2) Would mean that the Guest WiFi functionality can work even if the device is just an access point. Or maybe something else entirely?

    Read the article

  • Typecasting a floating value or using the math.h floor* functions?

    - by nobody
    Hi, I am coding up an implementation of Interpolation Search in C. The question is actually rather simple, I need to use the floating operations to do linear interpolation to find the correct index which will eventually be an integer result. In particular my probe index is: t = i + floor((((k-low)/(high-low)) * (j-i))); where, i,j,k,t are unsigned ints, and high,low are doubles. Would this be equivalent to: t = i + (unsigned int)(((k-low)/(high-low)) * (j-i)); Is there any reason I would actually want to use math.h floor* functions over just a simple (int) typecast?

    Read the article

  • Can I assume Flash and PHP will generate the same floating point numbers?

    - by Fragsworth
    In a multiplayer game I'm developing, we have a few values that are floating point numbers. The back-end (in PHP) and the front-end (in Flash) occasionally perform the same calculations on these numbers, to minimize communication. I am currently making sure that both sides are using 64-bit doubles, but am I safe to assume that all calculations will be the same? For instance, what about string to float conversion - should I worry about Flash having a potentially different implementation as PHP? (If this happens, our game will go out of sync - the client will think it is in one state while the server is in another) With some testing, it appears to be the same, but I'm just not sure. Can someone clarify this for me?

    Read the article

  • Rotating an object about a point (2D) using box2d

    - by noob
    i just started developing using box2d on flixel and i realise the pivot point of the rotation of an object in box2d is set to the center of an object. i had read on forums and i found out that SetAsBox can change the pivot point of the object, however, i cannot seem to get it work to rotate about a point. what i would like to achieve is to rotate an object about a point like earth revolving around the sun. any one can help me with it? really thanks a lot and sorry for the bad english

    Read the article

  • 3D Vector "End Point" Calculation for procedural Vector Graphics

    - by FrostFlame64
    Alright, So I need some help with some Vector Math. I've developing some game Engines that have Procedural Fractal Generation for Some Graphics, such as using Lindenmayer Systems for generating Trees and Plants. L-Systems, are drawn by using Turtle Graphics, which is a form of Vector graphics. I first created a system to draw in 2D Graphics, which works perfectly fine. But now I want to make a 3D equivalent, and I’ve run into an issue. For my 2D Version, I created a Method for quickly determining the “End Point” of a Vector-like movement. Given a starting point (X, Y), a direction (between 0 and 360 degrees), and a distance, the end point is calculated by these formulas: newX = startX + distance * Sin((PI * direction) / 180) newY = startY + distance * Cos((PI * direction) / 180) Now I need something Similarly Equivalent for performing this Calculation in 3D, But I haven’t been able to Google anything that could show me how to do this. I'm flexible enough to get whatever required information is needed for this method calculation, in any reasonable form (Vector3, Quaternion, ect). To summarize: Given a starting point/vector position in 3D space (X, Y, Z), a Direction in 3D space (Vector3, Quaternion, ect), and a Distance, I need to find the “End Point” in 3D Space. Thank you for your time and help.

    Read the article

  • iwconfig usage for WEP access point?

    - by johan elmander
    I would like to use my wifi doggle in my pc (ubuntu 12.04). I am able to connect to my access point through the GUI. I would like to do the same in the terminal. My access point uses WEP. So I typed the following commands iwconfig wlan0 mode managed key 6d6f6e6579 iwconfig wlan0 essid "AccessPoint" dhclient wlan0 after typing dhclient wlan0 it waits like 1-2 min then outputs nothing and cannot connect to the Access Point. iwconfig output: wlan0 IEEE 802.11bgn ESSID:"AccessPoint" Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm Retry long timit:7 RTS thr=2347 B Fragment thr:off Encryption key:6D6F-6E65-79 Power Management:off I would appreciate any suggestion

    Read the article

  • point to rectangle distance

    - by john smith
    I have a 2D rectangle with x, y position and it's height and width and a randomly positioned point nearby it. Is there a way to check if this point might collide with the rectangle if closer than a certain distance? like imagine an invisible radius outside of that point colliding with said rectangle. I have problems with this simply because it is not a square, it would be so much easier this way! Any help? Thanks in advance.

    Read the article

  • How to disable floating tabs in Visual Studio 2010

    - by md1337
    I now use the new Visual Studio 2010 and I experience something very annoying that wasn't happening before with Visual Studio 2008. Something changed with the way it handles the floating of tabs and I can't stand it. Every once in a while, I would somehow trigger the floating of a tab instead of just switching to it. It may have to do with the way I click (maybe a very fast double click gets sent), or maybe I very slightly drag the mouse when clicking the tab. I don't know. All I know is that I was fine with Visual Studio 2008. Is there a way to disable this somewhere? I want to either un-register the double click as a floating tab trigger, or remove the floating option altogether. How can I do that? Thanks.

    Read the article

  • floating constants in C

    - by Daziplqa
    Hi floks, I have a question concerning floating constants in C. In Java, the default type of floating point constants in double, so the following will causes a compilation error in java: float f = 100.0; // we either need to uses type case operator or put f at the end of the number constant. This is because the default floating-point constants are of type double and casting from double to float without type cast operator is an error, so we need either add a type case operator or put f at the end of the number. So, Why in C this doesn't produce an error, Is it because the default floating-point constants are of type float, or because the compiler do an implicit down-cast conversion (that doesn't requires type case operator in C)????

    Read the article

  • Floating Menu CSS/Javascript issues

    - by Ron Cassel
    I'm new to all this so thanks for being patient. Ok so I'm building a site with a Floating Javascript menu. The original code is from: Jtricks Absolute Floating Menu Here's the issue: When viewing the site in a mobile browser, zooming in initially caused the floating javascript menu to leave the far left of the page and cover content on the page. I fixed this by locking it into a fixed width div on the left side of the page. Now the issue I have is, I don't want the fancy animation of the javascript. A simple CSS script for a fixed window is fine. The only issue is, everything I've tried has done the same "free floating" thing when zoomed in on mobile browsers and I can't seem to find a fix. Anyone have any ideas?

    Read the article

  • Creating a floating button

    - by Robert Smith
    Hey all, I'm working on a Firefox extension and am out of ideas on how to implement a floating button. I need a button that is overlayed on my page that I can show/hide and dynamically position just about anywhere on my page. I thought I could do something like a fancy CSS tool-tip except replace it with button functionality, but that idea failed because I couldn't pull my example apart well enough to understand what all I need to include, need to change, etc. I've thought about using jQuery(though wouldn't mind avoiding, unless it makes this painfully easy) but will be looking more into that as a possibility now. If anyone can offer a tutorial link, ideas, sample code, anything to help get me moving in the right direction I will greatly appreciate it! Thanks! Edit: Clarification I'm not entirely sure how to actually create the overlayed button. I tried to create a a floating div with some text in it, and nothing showed up, but I got no errors, which means I'm doing something wrong, but I have no idea what that is. http://www.fijiwebdesign.com/blog/css-tooltips-floating-html-elements.html If you take a look at that webpage you see that there is that floating "feedback" button, I would like to create something similar, only it wouldn't be anchored to the sides, but I could position it over text, etc. #floatingBtn { position: absolute; z-index: 10000; top: 50%; left: 50%; } Thats the CSS I used to try and float my div. I don't know if I'm creating the div in the wrong place or... I thought if I could get a floating div with some text, I could turn that into my button.

    Read the article

  • SQL Server Transaction Marks: Restoring multiple databases to a common relative point

    - by Mladen Prajdic
    We’re all familiar with the ability to restore a database to point in time using the RESTORE WITH STOPAT statement. But what if we have multiple databases that are accessed from one application or are modifying each other? And over multiple instances? And all databases have different workloads? And we want to restore all of the databases to some known common relative point? The catch here is that this common relative point isn’t the same point in time for all databases. This common relative point in time might be now in DB1, now-1 hour in DB2 and yesterday in DB3. And we don’t know the exact times. Let me introduce you to Transaction Marks. When we run a marked transaction using the WITH MARK option a flag is set in the transaction log and a row is added to msdb..logmarkhistory table. When restoring a transaction log backup we can restore to either before or after that marked transaction. The best thing is that we don’t even need to have one database modifying another database. All we have to do is use a marked transaction with the same name in different database. Let’s see how this works with an example. The code comments say what’s going on. USE master GOCREATE DATABASE TestTxMark1GOUSE TestTxMark1GOCREATE TABLE TestTable1( ID INT, VALUE UNIQUEIDENTIFIER) -- insert some data into the table so we can have a starting pointINSERT INTO TestTable1SELECT ROW_NUMBER() OVER(ORDER BY number) AS RN, NULLFROM master..spt_valuesORDER BY RNSELECT *FROM TestTable1GO-- TAKE A FULL BACKUP of the databseBACKUP DATABASE TestTxMark1 TO DISK = 'c:\TestTxMark1.bak'GO USE master GOCREATE DATABASE TestTxMark2GOUSE TestTxMark2GOCREATE TABLE TestTable2( ID INT, VALUE UNIQUEIDENTIFIER)-- insert some data into the table so we can have a starting pointINSERT INTO TestTable2SELECT ROW_NUMBER() OVER(ORDER BY number) AS RN, NEWID()FROM master..spt_valuesORDER BY RNSELECT *FROM TestTable2GO-- TAKE A FULL BACKUP of our databseBACKUP DATABASE TestTxMark2 TO DISK = 'c:\TestTxMark2.bak'GO -- start a marked transaction that modifies both databasesBEGIN TRAN TxDb WITH MARK -- update values from NULL to random value UPDATE TestTable1 SET VALUE = NEWID(); -- update first 100 values from random value -- to NULL in different DB UPDATE TestTxMark2.dbo.TestTable2 SET VALUE = NULL WHERE ID <= 100;COMMITGO     -- some time goes by here -- with various database activity... -- We see two entries for marks in each database. -- This is just informational and has no bearing on the restore itself.SELECT * FROM msdb..logmarkhistory USE masterGO-- create a log backup to restore to mark pointBACKUP LOG TestTxMark1 TO DISK = 'c:\TestTxMark1.trn'GO-- drop the database so we can restore it backDROP DATABASE TestTxMark1GO USE masterGO-- create a log backup to restore to mark pointBACKUP LOG TestTxMark2 TO DISK = 'c:\TestTxMark2.trn'GO-- drop the database so we can restore it backDROP DATABASE TestTxMark2GO -- RESTORE THE DATABASE BACK BEFORE OUR TRANSACTION-- restore the full backup RESTORE DATABASE TestTxMark1 FROM DISK = 'c:\TestTxMark1.bak' WITH NORECOVERY;-- restore the log backup to the transaction markRESTORE LOG TestTxMark1 FROM DISK = 'c:\TestTxMark1.trn' WITH RECOVERY, -- recover to state before the transaction STOPBEFOREMARK = 'TxDb'; -- recover to state after the transaction -- STOPATMARK = 'TxDb';GO -- RESTORE THE DATABASE BACK BEFORE OUR TRANSACTION-- restore the full backup RESTORE DATABASE TestTxMark2 FROM DISK = 'c:\TestTxMark2.bak' WITH NORECOVERY;-- restore the log backup to the transaction markRESTORE LOG TestTxMark2 FROM DISK = 'c:\TestTxMark2.trn' WITH RECOVERY, -- recover to state before the transaction STOPBEFOREMARK = 'TxDb'; -- recover to state after the transaction -- STOPATMARK = 'TxDb';GO USE TestTxMark1-- we restored to time before the transaction -- so we have NULL values in our tableSELECT * FROM TestTable1 USE TestTxMark2-- we restored to time before the transaction -- so we DON'T have NULL values in our tableSELECT * FROM TestTable2   Transaction marks can be used like a crude sync mechanism for cross database operations. With them we can mark our databases with a common “restore to” point so we know we have a valid state between all databases to restore to.

    Read the article

  • Introducing Oracle Retail Mobile Point-of-Service

    - by user801960
    Normal 0 false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} Oracle recently announced the introduction of Oracle Retail Mobile Point-of-Service, a mobile extension to the Oracle Retail Point-of-Service (POS) used by many retailers internationally. Oracle Retail Mobile POS offers wide ranging cost and efficiency benefits by allowing staff resource to be used more effectively whilst also reducing spend associated with fixed POS solutions. For retailers utilising Oracle Retail Stores Solutions, additional benefits can be realised. Oracle Retail Mobile POS works with these solutions to allow store personnel to check in-store inventory, access product information and specifications, and perform tasks such as the printing or emailing of receipts and the activation of gift cards.  As Oracle Retail Mobile POS is an extension of Oracle Retail Point-of-Service, retailers can benefit from seamless integration with existing systems, simple upgrade procedures and seamless delivery across the business. However, the solution’s scalable and flexible architecture also supports multiple mobile operators and systems, so retailers are not locked into particular vendors. As well as being popular with retailers, Mobile POS has also proved to be well liked by consumers as it facilitates improved customer service levels. Retail staff are able to spend more time with consumers on the shop floor, access requested inventory information, and perform tasks that would traditionally have needed to be completed at a fixed cash register. Additional information can be accessed on Oracle Retail Point-of-Service or read the press announcement Oracle Introduces Mobile Point-of-Service for Retailers. Normal 0 false false false EN-US X-NONE X-NONE

    Read the article

  • Dual boot Win 7 Ubuntu - home and boot partitions have no mount point

    - by cwmff
    After installing Ubuntu 12.04.3 on a Windows 7 laptop, running Ubuntu Disk Utility showed the following partition information; /dev/sda1 NTFS, Bootable, Filesystem, Labled: System Reserved, 105MB, Not Mounted /dev/sda2 NTFS, no flag, Filesystem, no label, 84GB, Not Mounted /dev/sda3 Usage: Container for logical partitions. Partition Type: Extended (0x05). no flags. no label. Capacity: 416GB /dev/sda5 Usage: Filesystem. Partition Type: Linux (0x83). no partition label. no flags. Capacity: 999MB. Type: Ext4(ver 1.0). Available: -. Label: -. Mount Point: Not Mounted /dev/sda8 Usage: Filesystem. Partition Type: Linux (0x83). no partition label. no flags. Capacity: 30GB. Type: Ext4(ver 1.0). Available: -. Label: -. Mount Point: Mounted at / /dev/sda6 Usage: Filesystem. Partition Type: Linux (0x83). no partition label. no flags. Capacity: 377GB. Type: Ext4(ver 1.0). Available: -. Label: -. Mount Point: Not Mounted /dev/sda7 Usage: Swap Space. Partition Type: Linux (0x82). no partition label. no flags. Capacity: 8.4GB. sda2 contains Windows 7 but without a mount point sda6 should have been the Home partition and sda5 should have been the Boot partition but the mount points seem to have been lost and now everything but Swap has gone into the root partition sda8 (the Home folder also seems to be within sda8). How do I go about getting sda6 used as the Home partition and sda5 as Boot

    Read the article

  • Simulating an object floating on water

    - by Aaron M
    I'm working on a top down fishing game. I want to implement some physics and collision detection regarding the boat moving around the lake. I would like for be able to implement thrust from either the main motor or trolling motor, the effect of wind on the object, and the drag of the water on the object. I've been looking at the farseer physics engine, but not having any experience using a physics engine, I am not quite sure that farseer is suitable for this type of thing(Most of the demos seem to be the application of gravity to a vertical top/down type model). Would the farseer engine be suitable? or would a different engine be more suitable?

    Read the article

  • Deterministic Multiplayer RTS game questions?

    - by Martin K
    I am working on a cross-platform multiplayer RTS game where the different clients and a server(flash and C#), all need to stay deterministically synchronised. To deal with Floatpoint inconsistencies, I've come across this method: http://joshblog.net/2007/01/30/flash-floating-point-number-errors/#comment-49912 which basically truncates off the nondeterministic part: return Math.round(1000 * float) / 1000; Howewer my concern is that every time there is a division, there is further chance of creating additional floatpoint errors, in essence making it worse? . So it occured to me, how about something like this: function floatSafe(number:Number) : Number {return Math.round(float* 1024) / 1024; } ie dividing with only powers of 2 ? What do you think? . Ironically with the above method I got less accurate results: trace( floatSafe(3/5) ) // 0.599609375 where as with the other method(dividing with 1000), or just tracing the raw value I am getting 3/5 = 0.6 or Maybe thats what 3/5 actually is, IE 0.6 cannot really be represented with a floatpoint datatype, and would be more consistent across different platforms?

    Read the article

  • Find meeting point of 2 objects in 2D, knowing (constant) speed and slope

    - by Axonn
    I have a gun which fires a projectile which has to hit an enemy. The problem is that the gun has to be automatic, i.e. - choose the angle in which it has to shoot so that the projectile hits the enemy dead in the center. It's been a looooong time since school, and my physics skills are a bit rusty, but they're there. I've been thinking to somehow apply the v = d/t formula to find the time needed for the projectile or enemy to reach a certain point. But the problem is that I can't find the common point for both the projectile and enemy. Yes, I can find a certain point for the projectile, and another for the enemy, but I would need lots of tries to find where the point coincides, which is stupid. There has to be a way to link them together but I can't figure it out. I prepared some drawings and samples: A simple version of my Flash game, dumbed down to the basics, just some shapes: http://axonnsd.org/W/P001/MathSandBox.swf - click the mouse anywhere to fire a projectile. Or, here is an image which describes my problem: So... who has any ideas about how to find x3/y3 - thus leading me to find the angle in which the weapon has to tilt in order to fire a projectile to meet the enemy? EDIT I think it would be clearer if I also mention that I know: the speed of both Enemy and Projectile and the Enemy travels on a straight vertical line.

    Read the article

  • Should I use float, double, or decimal for stats, position, etc?

    - by Ryan Peschel
    The problem with float and double is that they are not exact. If you are to do something like store replays, the values would have to be exact. The problems with decimal is that they are approximately 16x slower (confirmed by searching and personal testing) than floats and doubles. Couldn't Vector2s be another problem because they use floats internally for all the components? How do other games solve this problem? I'm sure they must use floats and doubles but aren't they not deterministic across platforms and different architecture? The replay files for games like SC2 run in a linear fashion so you cannot skip ahead so how do they solve the determinism issue with floating point numbers?

    Read the article

  • 3d point cloud render from x,y,z 2d array with texture

    - by user1733628
    Need some direction on 3d point cloud display using OpenGL in c++ (vs2008). I am brand new to OpenGL and trying to do a 3d point cloud display with a texture. I have 3 2D arrays (each same size 1024x512) representing x,y,z of each point. I think I am on the right track with glBegin(GL_POLYGON); for(int i=0; i<1024; i++) { for(int j=0; j<512; j++) { glVertex3f(x[i][j], y[i][j], z[i][j]); } } glEnd(); Now this loads all the vertices in the buffer (I think) but from here I am not sure how to proceed. Or I am completely wrong here. Then I have another 2D array (same size) that contains color data (values from 0-255) that I want to use as texture on the 3D point cloud and display. I understand that this maybe a very basic OpenGL implementation for some but for me this is a huge learning curve. So any pointers, nudge or kick in the right direction will be appreciated.

    Read the article

  • Cloning from a given point in the snapshot tree

    - by Fat Bloke
    Although we have just released VirtualBox 4.3, this quick blog entry is about a longer standing ability of VirtualBox when it comes to Snapshots and Cloning, and was prompted by a question posed internally, here in Oracle: "Is there a way I can create a new VM from a point in my snapshot tree?". Here's the scenario: Let's say you have your favourite work VM which is Oracle Linux based and as you installed different packages, such as database, middleware, and the apps, you took snapshots at each point like this: But you then need to create a new VM for some other testing or to share with a colleague who will be using the same Linux and Database layers but may want to reconfigure the Middleware tier, and may want to install his own Apps. All you have to do is right click on the snapshot that you're happy with and clone: Give the VM that you are about to create a name, and if you plan to use it on the same host machine as the original VM, it's a good idea to "Reinitialize the MAC address" so there's no clash on the same network: Now choose the Clone type. If you plan to use this new VM on the same host as the original, you can use Linked Cloning else choose Full.  At this point you now have a choice about what to do about your snapshot tree. In our example, we're happy with the Linux and Database layers, but we may want to allow our colleague to change the upper tiers, with the option of reverting back to our known-good state, so we'll retain the snapshot data in the new VM from this point on: The cloning process then chugs along and may take a while if you chose a Full Clone: Finally, the newly cloned VM is ready with the subset of the Snapshot tree that we wanted to retain: Pretty powerful, and very useful.  Cheers, -FB 

    Read the article

  • opengl 3d point cloud render from x,y,z 2d array with texture

    - by user1733628
    Need some direction on 3d point cloud display using openGl in c++ (vs2008). I am brand new to openGl and trying to do a 3d point cloud display with a texture. I have 3 2D arrays (each same size 1024x512) representing x,y,z of each point. I think I am on the right track with glBegin(GL_POLYGON); for(int i=0; i<1024; i++) { for(int j=0; j<512; j++) { glVertex3f(x[i][j], y[i][j], z[i][j]); } } glEnd(); Now this loads all the vertices in the buffer (i think) but from here I am not sure how to proceed. Or I am completely wrong here. Then I have another 2D array (same size) that contains color data (values from 0-255) that I want to use as texture on the 3D point cloud and display. I understand that this maybe a very basic opengl implementation for some but for me this is a huge learning curve. So any pointers, nudge or kick in the right direction will be appreciated.

    Read the article

  • template; Point<2, double>; Point<3, double>

    - by Oops
    Hi, I want to create my own Point struct it is only for purposes of learning C++. I have the following code: template <int dims, typename T> struct Point { T X[dims]; Point(){} Point( T X0, T X1 ) { X[0] = X0; X[1] = X1; } Point( T X0, T X1, T X2 ) { X[0] = X0; X[1] = X1; X[2] = X2; } Point<dims, int> toint() { //how to distinguish between 2D and 3D ??? Point<dims, int> ret = Point<dims, int>( (int)X[0], (int)X[1]); return ret; } std::string str(){ //how to distinguish between 2D and 3D ??? std::stringstream s; s << "{ X0: " << X[0] << " | X1: " << X[1] << " }"; return s.str(); } }; int main(void) { Point<2, double> p2d = Point<2, double>( 12.3, 45.6 ); Point<3, double> p3d = Point<3, double>( 12.3, 45.6, 78.9 ); Point<2, int> p2i = p2d.toint(); //OK Point<3, int> p3i = p3d.toint(); //m??? std::cout << p2d.str() << std::endl; //OK std::cout << p3d.str() << std::endl; //m??? std::cout << p2i.str() << std::endl; //m??? std::cout << p3i.str() << std::endl; //m??? char c; std::cin >> c; return 0; } of couse until now the output is not what I want. my questions is: how to take care of the dimensions of the Point (2D or 3D) in member functions of the Point? many thanks in advance Oops

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >